fix(security): harden image proxy DNS rebinding, upload memory limits, and origin audit logging - #771
Draft
jermaine7511261 wants to merge 1 commit into
Draft
Conversation
- image_proxy: add DNS resolution check before outbound request to prevent DNS rebinding SSRF attacks. Resolves hostname and verifies IP is not in blocked ranges before making the HTTP request. - upload: add per-file size limit (20 MiB) to prevent memory exhaustion from large individual file uploads within the 100 MiB total limit. - origin: log WebSocket upgrades without Origin header for audit trail. Non-browser clients are still allowed but their access is now recorded. - outbound_http: document buildOutboundAllowedPorts memory allocation and add compact alternative for future optimization. Ref: source code audit findings
StackCairn
marked this pull request as draft
September 7, 2026 01:15
Contributor
|
PR governance checks failed — this PR has been converted to draft.
Fix the items above, then click Ready for review to re-run the checks. |
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
This PR addresses several security findings from a source code audit of the agent-gateway component.
Changes
1. Image Proxy DNS Rebinding Protection (
image_proxy.go)safeurlwith IP blocklist, but did not resolve DNS before the actual request. DNS rebinding attacks could return a safe IP during validation and a malicious (internal) IP during the request.validateImageProxyURLthat resolves the hostname and verifies all resolved IPs are not in blocked ranges before allowing the request.2. Per-File Upload Size Limit (
upload.go)maxPerFileUploadBytes = 20 MiBper-file limit withio.LimitReaderto prevent unbounded memory allocation. Returns413 Request Entity Too Largewith the specific file name when exceeded.3. WebSocket Origin Audit Logging (
origin.go)Originheader (non-browser clients) were silently allowed with no audit trail.slog.Debuglogging when no Origin header is present, recording the remote address for security audit purposes.4. Outbound Ports Documentation (
outbound_http.go)buildOutboundAllowedPorts()allocates a 65535-element[]intslice (~512 KB) at init time, passed as variadic arguments tosafeurl.buildOutboundAllowedPortsCompact()alternative for future optimization if the library supports range-based configuration.Testing
Related
Source code audit of the agent-gateway Go codebase, focusing on SSRF, memory safety, and security observability.