-
Notifications
You must be signed in to change notification settings - Fork 1.1k
fix: assorted small validation and robustness fixes #2450
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
base: main
Are you sure you want to change the base?
Changes from all commits
a7b953b
97c3f7b
0372ce9
9df28ac
877aee9
056e934
352a574
a72bed2
5d14ccd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -308,7 +308,8 @@ fn generate_security_notes(host: &str, port: u16, is_ssrf: bool) -> String { | |
| } | ||
|
|
||
| // High port numbers may indicate ephemeral services. | ||
| if port > 49152 { | ||
| // The IANA dynamic/private (ephemeral) range is 49152-65535 inclusive. | ||
| if port >= 49152 { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Critical (CWE-193; OWASP LLM06): This corrects only the sandbox-generated note. The gateway discards and recomputes notes through |
||
| notes.push(format!( | ||
| "Port {port} is in the ephemeral range — \ | ||
| this may be a temporary service." | ||
|
|
@@ -472,6 +473,15 @@ mod tests { | |
| assert!(notes.contains("SSRF")); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_security_notes_ephemeral_range_inclusive_boundary() { | ||
| // 49151 is just below the IANA ephemeral range; 49152 is the first | ||
| // ephemeral port and must be flagged. | ||
| assert!(!generate_security_notes("api.example.com", 49151, false).contains("ephemeral")); | ||
| assert!(generate_security_notes("api.example.com", 49152, false).contains("ephemeral")); | ||
| assert!(generate_security_notes("api.example.com", 65535, false).contains("ephemeral")); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_security_notes_internal_ip_uses_canonical_classifier() { | ||
| // RFC 1918 is 172.16.0.0/12 only: the old starts_with("172.") prefix | ||
|
|
||
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.
Warning:
short_hashstill uses&hash[..12], so a server response such asaaaaaaaaaaaépanics when byte 12 splits a UTF-8 character (CWE-248). Makeshort_hashselect the twelfth character boundary usingchar_indices()and add short/multibyte regression cases; that fixes both new call sites.