Skip to content

security: Phase 1 critical fixes (C-1 through C-7)#34

Merged
initializ-mk merged 2 commits intomainfrom
security/phase1-critical-fixes
Mar 20, 2026
Merged

security: Phase 1 critical fixes (C-1 through C-7)#34
initializ-mk merged 2 commits intomainfrom
security/phase1-critical-fixes

Conversation

@initializ-mk
Copy link
Contributor

Summary

Fixes #30 — Phase 1 Critical SSRF Bypasses, Missing Auth & Security Headers (C-1 through C-6).

  • C-1/C-2/C-7: SSRF bypass protection — Strict IPv4 parser rejects octal, hex, packed decimal, leading-zero IP forms. SafeDialer validates resolved IPs post-DNS against blocked CIDRs (prevents DNS rebinding). IPv6 transition addresses (NAT64, 6to4, Teredo) embedding private IPv4 are detected and blocked.
  • C-3: Redirect credential strippinghttp_request and webhook_call strip Authorization, Cookie, Proxy-Authorization headers on cross-origin redirects.
  • C-4: CORS restriction — A2A server restricts Access-Control-Allow-Origin to localhost by default. Configurable via --cors-origins flag, FORGE_CORS_ORIGINS env var, or cors_origins in forge.yaml.
  • C-5: Authentication — Already implemented (256-bit tokens, constant-time comparison). No changes needed.
  • C-6: Security response headers — All A2A responses include X-Content-Type-Options: nosniff, Referrer-Policy: no-referrer, X-Frame-Options: DENY, Content-Security-Policy: default-src 'none'.

Container/K8s Awareness

allowPrivateIPs auto-detects container environments — allows RFC 1918 in Docker/K8s (needed for pod-to-pod comms) while always blocking cloud metadata (169.254.169.254) and loopback bypass vectors.

New Files

File Purpose
forge-core/security/ip_validator.go Strict IP parsing, CIDR blocking, IPv6 transition detection
forge-core/security/safe_dialer.go Post-DNS-resolution IP validation, SafeTransport
forge-core/security/redirect.go Cross-origin redirect credential stripping
forge-cli/server/a2a_server_test.go CORS + security header tests

Modified Files (22 total, +1324 -67 lines)

Egress enforcer, egress proxy, domain matcher, types, config, runner, A2A server, serve/run commands, http_request, webhook_call, and all related tests.

Test plan

  • cd forge-core && go test ./security/... -v -count=1 — IP validator, safe dialer, redirect, enforcer, proxy tests
  • cd forge-core && go test ./tools/... -v -count=1 — http_request and webhook_call with redirect policy
  • cd forge-cli && go test ./server/... -v -count=1 — A2A server CORS and security header tests
  • Manual: curl -i -H "Origin: https://evil.com" http://127.0.0.1:8080/ returns no CORS headers
  • Manual: Verify X-Content-Type-Options, X-Frame-Options headers on all responses

- C-1/C-2/C-7: Add strict IPv4 parsing to reject octal/hex/packed SSRF
  bypass vectors, SafeDialer with post-DNS-resolution IP validation,
  IPv6 transition address detection (NAT64, 6to4, Teredo), and
  container-aware allowPrivateIPs for K8s inter-service communication
- C-3: Strip Authorization/Cookie headers on cross-origin redirects in
  http_request and webhook_call tools
- C-4: Replace wildcard CORS with origin allowlist (localhost defaults),
  configurable via --cors-origins flag, FORGE_CORS_ORIGINS env, or
  forge.yaml cors_origins field
- C-6: Add X-Content-Type-Options, Referrer-Policy, X-Frame-Options,
  and Content-Security-Policy headers to all A2A server responses
Sync documentation to reflect IP validation, SafeDialer, CORS
restriction, security headers, redirect credential stripping,
and container-aware allowPrivateIPs across 6 doc files.
@initializ-mk initializ-mk merged commit 8a3a303 into main Mar 20, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Phase 1 — Critical SSRF Bypasses, Missing Auth & Security Headers (C-1 through C-6)

1 participant