Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,12 @@ try {
exit(0)
}

const otp = readline.question('Enter your npm OTP code: ')

log('Publishing...')
if (exec(`cd ${outDir} && npm publish --access public `).code !== 0) {
if (
exec(`cd ${outDir} && npm publish --access public --otp=${otp}`).code !== 0
Comment on lines +142 to +146
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Command injection vulnerability: the OTP input is directly interpolated into a shell command without validation. If a user enters 123456; rm -rf /, it would execute the malicious command. Validate that OTP contains only digits (typically 6 digits).

Suggested change
const otp = readline.question('Enter your npm OTP code: ')
log('Publishing...')
if (exec(`cd ${outDir} && npm publish --access public `).code !== 0) {
if (
exec(`cd ${outDir} && npm publish --access public --otp=${otp}`).code !== 0
const otp = readline.question('Enter your npm OTP code: ')
// Validate OTP is numeric
if (!/^\d{6}$/.test(otp)) {
logError('Invalid OTP format. OTP must be 6 digits.')
exit(1)
}
log('Publishing...')
if (
exec(`cd ${outDir} && npm publish --access public --otp=${otp}`).code !== 0
) {

) {
logError('Publish failed. Aborting release.')
exit(1)
}
Expand Down