Skip to content

Commit e7127a1

Browse files
committed
Let each test account say what it may and may not do, and judge cross account findings by it
The cross account access checks could prove one account reached another's object, but not whether that was wrong: a read only auditor is meant to see everything, and reporting it as a bug is noise. Now each test account, the first and the second, has a field for what that login should and should not be able to do. The compare check carries both descriptions into the finding, states them in the evidence, and frames the question: is the first account reaching this object within what it is meant to do, or not. The enhanced review is given the same two descriptions and told to decide, calling it a false positive when the access is within the stated role and a real broken access control when it is outside it, or asking a person to confirm when no role was given. The two proof screenshots, what each account sees, stay for a person to compare alongside it.
1 parent 10a476b commit e7127a1

5 files changed

Lines changed: 63 additions & 11 deletions

File tree

‎app/core/dast_checks/engine.py‎

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,14 @@ def live(client, who, url):
604604
break
605605
if confirmations == retest and confirmations > 0 and resp_a is not None:
606606
f = _finding(spec, a, resp_a, url)
607-
f["evidence"] = _two_account_evidence(url, resp_a, resp_b, resp_anon)
607+
intent_a = str(ctx.get("intent_a") or "")
608+
intent_b = str(ctx.get("intent_b") or "")
609+
if intent_a:
610+
f["intent_a"] = intent_a
611+
if intent_b:
612+
f["intent_b"] = intent_b
613+
f["evidence"] = _two_account_evidence(url, resp_a, resp_b, resp_anon,
614+
intent_a, intent_b)
608615
f["reproduce"] = _two_account_reproduce(url)
609616
# The proof is two pictures: what each account sees at this address,
610617
# captured later with each account's session. proof_url is what to
@@ -626,7 +633,7 @@ def _two_account_reproduce(url) -> str:
626633
f"(it is turned away). This is how the finding was confirmed.")
627634

628635

629-
def _two_account_evidence(url, resp_a, resp_b, resp_anon) -> str:
636+
def _two_account_evidence(url, resp_a, resp_b, resp_anon, intent_a="", intent_b="") -> str:
630637
"""Spell out what the two account check actually saw, so the finding is
631638
specific: the address, the status each account got, whether the first
632639
account saw the same page as the second, and whether a signed out visitor
@@ -646,11 +653,22 @@ def _two_account_evidence(url, resp_a, resp_b, resp_anon) -> str:
646653
+ (", so the page is not simply public." if an_st != 200
647654
else ", so a signed out visitor sees it too."))
648655
bits.append("Confirmed and re-tested.")
649-
bits.append("Validate this before acting on it: if the two accounts are meant "
650-
"to share this access, for example a read only auditor role that "
651-
"can see everything, it is expected; re-categorise its severity or "
652-
"mark it a false positive.")
653-
return " ".join(bits)[:1100]
656+
if intent_a or intent_b:
657+
if intent_a:
658+
bits.append(f"The first account is described as: {intent_a}")
659+
if intent_b:
660+
bits.append(f"The second account is described as: {intent_b}")
661+
bits.append("Judge the finding against those descriptions: if the first "
662+
"account reaching this object is within what it is meant to do "
663+
"(for example a read only auditor that may see everything), it "
664+
"is expected, so re-categorise it or mark it a false positive; "
665+
"if it is not, it is a real broken access control.")
666+
else:
667+
bits.append("Validate this before acting on it: if the two accounts are "
668+
"meant to share this access, for example a read only auditor "
669+
"role that can see everything, it is expected; re-categorise "
670+
"its severity or mark it a false positive.")
671+
return " ".join(bits)[:1600]
654672

655673

656674
# Alias labels for the amplification probe. Valid GraphQL names, ours so they

‎app/core/external.py‎

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2244,6 +2244,10 @@ def _fresh_headers(auth):
22442244
"code_routes": list(wb.get("routes") or []),
22452245
"headers": headers or None, "second_headers": second_headers,
22462246
"reauth_a": reauth_a, "reauth_b": reauth_b,
2247+
# What each account is meant to be able to do, so a cross account read
2248+
# can be judged against the intended policy, not just reported.
2249+
"intent_a": (auth_a or {}).get("intent", ""),
2250+
"intent_b": (auth_b or {}).get("intent", ""),
22472251
"budget": 60, "oob": oob}
22482252
from collections import Counter
22492253

@@ -3766,6 +3770,15 @@ def recover() -> int:
37663770
results, so use it only when the evidence shows it is noise. When unsure, say \
37673771
needs_review. A finding about an exposed secret stays whatever you say.
37683772

3773+
For a cross account, broken access finding, judge it against what each account \
3774+
is meant to do (account_a_is_meant_to and account_b_is_meant_to, when given): \
3775+
if the first account reaching the second account's object is within its stated \
3776+
role, for example a read only auditor that may see everything, call it \
3777+
likely_false_positive and say which part of the stated role makes it expected; \
3778+
if reaching that object is outside its stated role, it is likely_real, a true \
3779+
broken access control. With no stated role, say needs_review and that a person \
3780+
must confirm the intended access.
3781+
37693782
2) Write "why" as a short risk narrative for an engineer, three to five \
37703783
sentences, in this order:
37713784
- what can go wrong: what an attacker gains if the finding is real, and, when \
@@ -3992,8 +4005,10 @@ def triage(scan_id: int, actor: str = "") -> None:
39924005
"dast_findings": [{"id": f.get("id") or f["key"], "tool": f.get("tool"),
39934006
"severity": f.get("severity"), "title": _clean(f.get("title")),
39944007
"url": _clean(f.get("url"))[:300],
3995-
"evidence": _clean(f.get("evidence"))[:300],
4008+
"evidence": _clean(f.get("evidence"))[:600],
39964009
"cwe": f.get("cwe"),
4010+
"account_a_is_meant_to": f.get("intent_a") or "",
4011+
"account_b_is_meant_to": f.get("intent_b") or "",
39974012
"computed_likelihood": f.get("likelihood_label"),
39984013
"computed_impact": f.get("breachability_label"),
39994014
"computed_risk": f.get("risk"),

‎app/core/external_auth.py‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ def describe(asset, slot: str = "a") -> dict:
7676
set_at = getattr(asset, at_attr, None)
7777
out = {"kind": data["kind"], "kind_name": KINDS.get(data["kind"], data["kind"]),
7878
"set_by": getattr(asset, by_attr, "") or "",
79-
"set_at": set_at.isoformat() if set_at else None}
79+
"set_at": set_at.isoformat() if set_at else None,
80+
"intent": data.get("intent", "")}
8081
if data["kind"] == "header":
8182
out["header_name"] = data.get("header_name", "")
8283
elif data["kind"] == "cookie":
@@ -157,6 +158,16 @@ def save(asset, kind: str, values: dict, actor: str, parent_domain: str = "",
157158
raise ValueError(f"{what} is the name of the form field, such as email.")
158159
if field:
159160
data[key] = field
161+
# What this login is meant to be able to do, and not do. Free text, not a
162+
# secret: it is the intended authorization policy for the account, which the
163+
# compare checks and the review weigh a cross account read against. Kept
164+
# across a change of sign in kind, since it describes the account, not how
165+
# it signs in.
166+
prior = load(asset, slot)
167+
new_intent = str(values.get("intent") or "").strip()[:2000]
168+
intent = new_intent or prior.get("intent", "")
169+
if intent:
170+
data["intent"] = intent
160171
setattr(asset, kind_attr, kind)
161172
setattr(asset, data_attr, _encrypt(data))
162173
setattr(asset, by_attr, (actor or "")[:120])

‎app/web/routes_external.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,12 +489,12 @@ def on(name):
489489
changes["auth"] = (str(form.get("auth_kind") or ""), {
490490
key: form.get(f"auth_{key}") or "" for key in (
491491
"header_name", "header_value", "cookie", "login_url", "username",
492-
"password", "username_field", "password_field")})
492+
"password", "username_field", "password_field", "intent")})
493493
if on("auth_b"):
494494
changes["auth_b"] = (str(form.get("auth_b_kind") or ""), {
495495
key: form.get(f"auth_b_{key}") or "" for key in (
496496
"header_name", "header_value", "cookie", "login_url", "username",
497-
"password", "username_field", "password_field")})
497+
"password", "username_field", "password_field", "intent")})
498498
if on("repositories"):
499499
changes["repositories"] = (str(form.get("repositories_mode") or "add"),
500500
external.parse_picks(form.getlist("pick")))

‎app/web/templates/external_site.html‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,10 @@
428428
<label>User name field <input type="text" name="auth_username_field" maxlength="100" value="{{ auth.username_field if auth and auth.username_field else '' }}" placeholder="found on the page"></label>
429429
<label>Password field <input type="text" name="auth_password_field" maxlength="100" value="{{ auth.password_field if auth and auth.password_field else '' }}" placeholder="found on the page"></label>
430430
</div>
431+
<label>What this login should and should not do
432+
<textarea name="auth_intent" rows="2" maxlength="2000"
433+
placeholder="e.g. a standard user: should see only its own orders and profile; should not see other customers or any admin page.">{{ auth.intent if auth and auth.intent else '' }}</textarea>
434+
<span class="faint small">Optional. Used by the compare checks and the AI review to tell a real access violation from expected, shared access.</span></label>
431435
<div class="faint small">Use a test account. A signed in scan can change what that user can change.</div>
432436
</details>
433437
<details class="hand-fields" {{ 'open' if auth_b }}>
@@ -455,6 +459,10 @@
455459
<label>User name field <input type="text" name="auth_b_username_field" maxlength="100" value="{{ auth_b.username_field if auth_b and auth_b.username_field else '' }}" placeholder="found on the page"></label>
456460
<label>Password field <input type="text" name="auth_b_password_field" maxlength="100" value="{{ auth_b.password_field if auth_b and auth_b.password_field else '' }}" placeholder="found on the page"></label>
457461
</div>
462+
<label>What the second account should and should not do
463+
<textarea name="auth_b_intent" rows="2" maxlength="2000"
464+
placeholder="e.g. a read-only auditor: may view all records but must not edit; or a different standard user that owns different data than the first.">{{ auth_b.intent if auth_b and auth_b.intent else '' }}</textarea>
465+
<span class="faint small">The compare checks and the AI review weigh a cross-account read against this, so an auditor that is meant to see everything is not reported as a bug.</span></label>
458466
<div class="faint small">Use a second test account that owns different data than the first. That is what lets the compare checks prove one account can reach the other's objects.</div>
459467
</details>
460468
<details class="hand-fields">

0 commit comments

Comments
 (0)