mirror of
https://github.com/openai/codex.git
synced 2026-11-18 15:01:48 +00:00
Harden network proxy MITM authorization (#37211)
## Why MITM hooks authorize requests before the upstream server parses them. Paths that can be decoded or normalized to a different resource must not match an allowed path, and hosts that require MITM inspection must not bypass it through the plain HTTP proxy path. ## What changed - Reject ambiguous hook paths, including traversal segments, backslashes, malformed percent encodings, and encoded separators or percent signs. - Block plain HTTP proxy requests for hosts whose policy always requires MITM, recording the decision as `mitm_required`. ## Testing - Cover safe and ambiguous path forms, encoded traversal through repository allowlists, and absolute-form HTTPS requests sent to the HTTP proxy. GitOrigin-RevId: 8812a980ac64a97cbac3a237376d29be5ded9220
This commit is contained in:
1 parent
1ae82ce6a5
commit
7a0e974e08
6 files changed
+353
-1
No files matched your search
@@ -0,0 +1,46 @@
|
||||
use super::is_safe_for_authorization;
|
||||
use pretty_assertions::assert_eq;
|
||||
|
||||
#[test]
|
||||
fn accepts_unambiguous_paths() {
|
||||
let paths = [
|
||||
"/openai/openai",
|
||||
"/openai/openai/issues/123",
|
||||
"/openai/openai/a..b",
|
||||
"/openai/openai/%20space",
|
||||
"/openai/openai/%E2%9C%93",
|
||||
"/openai/openai/contents/%2Egitignore",
|
||||
"/openai/openai/contents/.%2Egithub",
|
||||
"/openai/openai/%2e%2efoo",
|
||||
"/openai/openai/%2e%2e%2e",
|
||||
];
|
||||
|
||||
assert_eq!(
|
||||
paths.map(is_safe_for_authorization),
|
||||
[true, true, true, true, true, true, true, true, true]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn rejects_paths_with_ambiguous_segments_or_encodings() {
|
||||
let paths = [
|
||||
"/openai/openai/../codex",
|
||||
"/openai/openai/./issues",
|
||||
"/openai/openai\\..\\codex",
|
||||
"/openai/openai/%2e%2e/codex",
|
||||
"/openai/openai/%2E%2E/codex",
|
||||
"/openai/openai/%2f..%2fcodex",
|
||||
"/openai/openai/%5c..%5ccodex",
|
||||
"/openai/openai/%252e%252e/codex",
|
||||
"/openai/openai/%",
|
||||
"/openai/openai/%2",
|
||||
"/openai/openai/%zz",
|
||||
];
|
||||
|
||||
assert_eq!(
|
||||
paths.map(is_safe_for_authorization),
|
||||
[
|
||||
false, false, false, false, false, false, false, false, false, false, false
|
||||
]
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user