-
Notifications
You must be signed in to change notification settings - Fork 47
Add input validation and improve SOCKS5 authentication security #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
39ff
merged 2 commits into
claude/squid-socks-proxy-support-CqoL5
from
claude/security-review-33NY5
May 3, 2026
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ログインジェクション: 拒否理由に不正値を素のままで埋め込んでいます。
$reject_unsafeは\s(改行含む)にマッチすると即continueしますが、その直前に$proxyInfo['host']をそのままSTDERRに書き出しています。悪意あるproxyList.txtの 1 行にevil\nFAKE LOG LINEのような値が含まれる場合、ログが複数行に分割され、下流のログ集約で偽のエントリを注入できます。port 側(Line 49)も、非数値で任意バイトが来る可能性があるため同じリスクがあります(Line 57/61 の host はこの時点で既に検証済みなので安全)。出力前にサニタイズ(例えば
rawurlencodeもしくはaddcslashesによる制御文字のエスケープ)するのが安全です。🛡️ 提案パッチ
// Validate host: hostname or IPv4/IPv6 literal. No shell/conf metachars. if (preg_match($reject_unsafe, $proxyInfo['host']) || !preg_match('/^[A-Za-z0-9.:\[\]_-]+$/', $proxyInfo['host'])) { - fwrite(STDERR, "Skipping proxy with invalid host: " . $proxyInfo['host'] . PHP_EOL); + fwrite(STDERR, "Skipping proxy with invalid host: " . rawurlencode($proxyInfo['host']) . PHP_EOL); continue; } // Validate port: 1-65535. if (!ctype_digit((string)$proxyInfo['port']) || (int)$proxyInfo['port'] < 1 || (int)$proxyInfo['port'] > 65535) { - fwrite(STDERR, "Skipping proxy with invalid port: " . $proxyInfo['port'] . PHP_EOL); + fwrite(STDERR, "Skipping proxy with invalid port: " . rawurlencode((string)$proxyInfo['port']) . PHP_EOL); continue; }Also applies to: 49-49
🤖 Prompt for AI Agents