test(security): plaintext forged-header regression + proxy hardening (audit #31, P5)#36
Merged
Merged
Conversation
…o_existing_atom (audit #31, P5) Two small defence-in-depth items from the priority-5 audit finding: 1. proxy.ex still used String.to_existing_atom/1 on conn.method. By the time we reach make_backend_request/4, Gateway.safe_verb/1 has already filtered for the seven supported methods — so to_existing_atom would not crash on real traffic. But the moduledoc comment in gateway.ex claims the gateway NEVER uses to_existing_atom on user input, which was half-true: this internal path did. Closed the gap with an explicit @method_atoms map so that grep'ing for `to_existing_atom` returns zero hits on any user-input path. 2. The existing strip-untrusted-headers describe block asserts only on `conn.assigns[:trust_level]`. Added an end-to-end regression net that asserts on the actual *response* the forged client receives against a route whose exposure is :internal: - forged "internal" from 10.0.0.99 -> 403 (NOT 200/502) - forged "authenticated" from 203.0.113.7 -> 403 - real "internal" from loopback -> 502 (i.e. allowed past policy to the down backend; CONTROL case so we know we're not just blocking everything) - garbage "ADMIN_OVERRIDE" header -> 403 Refs: #31 (self-audit, priority 5)
🔍 Hypatia Security ScanFindings: 65 issues detected
View findings[
{
"reason": "Issue in boj-build.yml",
"type": "missing_timeout_minutes",
"file": "boj-build.yml",
"action": "flag",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in casket-pages.yml",
"type": "missing_timeout_minutes",
"file": "casket-pages.yml",
"action": "flag",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in casket-pages.yml",
"type": "missing_timeout_minutes",
"file": "casket-pages.yml",
"action": "flag",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in codeql.yml",
"type": "missing_timeout_minutes",
"file": "codeql.yml",
"action": "flag",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in dogfood-gate.yml",
"type": "missing_timeout_minutes",
"file": "dogfood-gate.yml",
"action": "flag",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in dogfood-gate.yml",
"type": "missing_timeout_minutes",
"file": "dogfood-gate.yml",
"action": "flag",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in dogfood-gate.yml",
"type": "missing_timeout_minutes",
"file": "dogfood-gate.yml",
"action": "flag",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in dogfood-gate.yml",
"type": "missing_timeout_minutes",
"file": "dogfood-gate.yml",
"action": "flag",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in dogfood-gate.yml",
"type": "missing_timeout_minutes",
"file": "dogfood-gate.yml",
"action": "flag",
"rule_module": "workflow_audit",
"severity": "medium"
},
{
"reason": "Issue in governance.yml",
"type": "missing_timeout_minutes",
"file": "governance.yml",
"action": "flag",
"rule_module": "workflow_audit",
"severity": "medium"
}
]Powered by Hypatia Neurosymbolic CI/CD Intelligence |
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
Audit issue: #31 (priority 5 — auth/bypass weaknesses and test coverage).
Two small defence-in-depth items:
proxy.exstill usedString.to_existing_atom/1onconn.method.By the time we reach
make_backend_request/4,Gateway.safe_verb/1has already filtered for the seven supported methods — so
to_existing_atomwould not crash on real traffic. But the moduledocin
gateway.exclaims the gateway NEVER usesto_existing_atomonuser input, which was half-true: this internal path did. Closed the
gap with an explicit
@method_atomsmap so thatgrepforto_existing_atomreturns zero hits on any user-input path.The existing strip-untrusted-headers describe block in
test/security_test.exsonly asserts onconn.assigns[:trust_level].Added an end-to-end regression that asserts on the actual response
the forged client receives against a route whose exposure is
:internal:\"internal\"from10.0.0.99→ 403 (NOT 200/502)\"authenticated\"from203.0.113.7→ 403\"internal\"from loopback → 502 (allowed past policy to thedown backend; control case so we know we're not just blocking
everything)
\"ADMIN_OVERRIDE\"header → 403Diff: 2 files, +140 / -1 LoC.
Test plan
mix test test/forged_trust_e2e_test.exsmix test— confirm no existing tests broke (the proxy methodchange is a pure refactor of the
String.downcase |> to_existing_atomidiom to a static map; behaviour is identical for valid methods)
grep -r \"to_existing_atom\" lib/should show only test/protocolrouter contexts, not any user-input path
Echo-types audit
record-as-not-relevant. Regression test + atom-table hardening; no L3obligation in scope.
Refs: #31