broken-access-control
Replay captured requests with swapped identities and bumped object IDs to surface broken access control. Use when testing for IDOR or authz flaws.
forefy · 已有 AI 审核记录
安装与使用
运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。
npx skills add forefy/.context --skill broken-access-control技能说明
name: broken-access-control description: Replay captured requests with swapped identities and bumped object IDs to surface broken access control. Use when testing for IDOR or authz flaws.
Contents
- Scope & authorization
- Methodology (baseline, identity-swap, numeric IDOR)
- Runnable snippets
- IDOR numeric-parameter wordlist
- Thresholds (carry these exactly)
- Output
Scope & authorization
Only run against an application the user owns or is contractually engaged to test. This is an ACTIVE, aggressive check: it re-sends real requests to the target under different identities and with mutated object-ids, so it creates traffic, may read or touch other users' data, and can trip rate-limits or alerts. Use a staging environment or a maintenance window where you can, keep the identities and object-ids to accounts you control, and stop if you start returning data that clearly belongs to real third parties. If scope is unclear, ask before replaying.
Two things must exist before you start:
- A capture of the target's traffic taken as a privileged / higher-role user (from a proxy, HAR export, or your own request log). Each captured request gives you the method, URL, headers, query params, cookies, and body.
- At least one second identity to replay under - a lower-privileged user's session, and/or the unauthenticated (no-token, no-cookie) state. An identity is either a cookie (
name=value) or a bearer token (Authorization: Bearer ...).
This skill covers authorization replay and numeric IDOR on already-captured requests. It does not fuzz for hidden endpoints, mutate non-numeric/UUID object references, or bypass auth at the token layer (JWT tampering, session fixation) - note those as unrun if the target warrants a deeper pass.
Methodology (run in order; each step is a check with a result state)
-
Inventory the capture. From the privileged capture, list each request as its parts: method, full URL, headers, query params, cookies, body. These are the units you replay; you never craft new endpoints, only re-send captured ones under new conditions.
-
Baseline each request as the privileged user. Re-send it exactly as captured and record
status_codeand response body length. This is the reference every swapped-identity and mutated-id response is compared against, and it confirms the request still works before you draw conclusions from a difference. -
Swap identity, replay unchanged (authorization check). For every captured request, replace only the identity - drop in each second identity's cookie or
Authorizationheader in place of the privileged one, leaving method, URL, params, and body identical. Compare each replay's(status_code, length)to the privileged baseline. Report a finding when a lesser or unauthenticated identity returns a success status with a body within 50 bytes of the privileged length (i.e.abs(length_diff) <= 50and no status change) - the low-priv session is being served the privileged response. The source's own trigger is the inverse framing: it flags a pair as differing whenlength_diff > 50or the status differs, so a non-differing successful pair across two different identities is the access-control failure. -
Find numeric object-id params. In each captured request's query params, match parameter names against the IDOR wordlist below. Keep only params whose value parses as an integer - these are the candidate direct object references.
-
Baseline the id param. Re-send the request with its original numeric id (under the identity that legitimately owns that object) and record
baseline_status("<code> <reason>") andbaseline_body_len(length of the parsed JSON response). Skip the param if the response is not JSON or the length is zero - there is nothing to compare. -
Increment the id, twice (IDOR check). Send the same request twice more, changing only that one param: once at
original + 1(first_attempt_size_increase = 1), once atoriginal + 100(second_attempt_size_increase = 100). Record status and JSON length for each. Two offsets cover both a densely-packed id space (neighbour exists at +1) and a sparser one (+100 lands on another live object). -
Decide IDOR. Report a finding when the +1 attempt returns the same status as the baseline AND either mutated attempt's JSON length differs from the baseline by at least
response_body_length_diff = 3. Same success status across a different id means the object still resolves under your identity; a body-length difference of >= 3 means you got a different object's data rather than an empty/error shell. Same status with a near-identical length is the ambiguous "same template, maybe empty" case and is not reported on its own. -
Cross the two checks. The strongest finding is a captured request where an id-param increment (steps 4-7) succeeds and the same request replays successfully under a lower-privileged or unauthenticated identity (step 3): an object reference that is both enumerable and unprotected by the session.
Runnable snippets
Set the target and the privileged identity once. PRIV_COOKIE/PRIV_AUTH come from your privileged capture; LOW_COOKIE/LOW_AUTH are the second identity; empty strings are the unauthenticated case.
BASE="https://TARGET"
PRIV_COOKIE="session=PRIV_SESSION_VALUE"
PRIV_AUTH="Authorization: Bearer PRIV_TOKEN"
LOW_COOKIE="session=LOW_SESSION_VALUE"
LOW_AUTH="Authorization: Bearer LOW_TOKEN"
# 2 baseline a captured request as the privileged user (status + body length)
curl -sk -o /dev/null -w '%{http_code} %{size_download}b\n' \
-H "$PRIV_AUTH" -b "$PRIV_COOKIE" "$BASE/api/report?client_id=1024"
# 3 authorization check: replay the SAME request under each identity, compare
REQ="/api/report?client_id=1024"
for id in "priv:$PRIV_AUTH:$PRIV_COOKIE" "low:$LOW_AUTH:$LOW_COOKIE" "anon:::"; do
name="${id%%:*}"; rest="${id#*:}"; auth="${rest%%:*}"; cook="${rest#*:}"
阅读完整来源 ↗