react-doctor/clickjacking-redirect-risk
A redirect target taken from caller input, or a privileged page that allows untrusted framing, lets attackers send users to malicious sites or trick them through clickjacking.
- Status
- Active
- Category
- Security
- Assessment
- Evidence-required risk
- Required evidence
- source code, repository context
- Default configuration
- Enabled
- Default severity
- warn
Show technical metadata
- Scope
- All supported frameworks
- Active when
- production source files (.js/.ts/.tsx) or config/CI files; tests/build/docs/generated paths skipped
- Tags
- security-scan
- Priority
- 64 (P2)
- Source
- oxlint-plugin-react-doctor
- Rule set
- oxlint-plugin-react-doctor 0.9.3 (prompt schema 2)
Validation prompt
Confirm the detector match and collect the required evidence before deciding whether an edit is warranted.
Fires in production source or config/CI files on four shapes: (1) a redirect(...) call whose argument is attacker-controllable caller input: a bare identifier/property referencing searchParams.get/nextUrl.searchParams/returnTo/callbackUrl/continue/next (open redirect); (2) an <iframe> whose markup within ~700 chars carries redirect/URL-param shapes like next=/continue=/redirect=/redirect_uri/role=/..; (3) a frame-ancestors * (or 'self' *) CSP; or (4) an X-Frame-Options: ALLOW… header. Comments are stripped first.
Suppress when: already exempted: a redirect keyword that appears only inside a string literal (e.g. redirect('/login?...continue...')) and a target already passed through a safe*/valid*/sanitiz*/allowlist/whitelist helper are skipped; a remaining FP is a next/returnTo value already validated against a same-origin or path allowlist before this redirect().
Evidence boundary
The diagnostic proves only that the detector’s modeled source pattern matched. It does not prove runtime impact, product intent, rendered failure, or that one remediation is correct.
Establish the environment, repository policy, exceptions, and required rendered or runtime evidence before deciding the occurrence.
Record one outcome:
- Confirmed failure: The required evidence establishes the violation.
- Rejected: A documented exception or false-positive predicate applies.
- Needs evidence: Named evidence can still be collected.
- Unavailable: Required evidence cannot be collected in this run.
- Waived with evidence: An authorized, scoped exception applies to an established failure.
- Observation: The review records an optional tradeoff without claiming a defect.
A waiver records its scope, authority, evidence, and review condition. It is not a pass or false positive.
Default severity is registry metadata. Use the occurrence’s JSON severity after repository configuration when ordering real findings.
Fix prompt
Apply this candidate correction only after the required evidence confirms the risk.
For redirects, validate the target against a strict allowlist of paths or origins (or force it relative: reject anything not starting with a single /, and reject //) before calling redirect(), ideally through one shared getSafeRedirectUrl() helper. For framing, set Content-Security-Policy: frame-ancestors 'self' (or specific trusted origins) on privileged pages and avoid X-Frame-Options: ALLOW…. Do not embed privileged flows in URL-driven <iframe>s or URL-prefilled dialogs.
Repository-wide copy prompt
Use this repository-wide prompt only after validating each occurrence. For one occurrence, use the guidance above.
Show repository-wide prompt
Fix every confirmed react-doctor/clickjacking-redirect-risk diagnostic in the current repository.
Required change:
- For redirects, validate the target against a strict allowlist of paths or origins (or force it relative: reject anything not starting with a single
/, and reject//) before callingredirect(), ideally through one sharedgetSafeRedirectUrl()helper. For framing, setContent-Security-Policy: frame-ancestors 'self'(or specific trusted origins) on privileged pages and avoidX-Frame-Options: ALLOW…. Do not embed privileged flows in URL-driven<iframe>s or URL-prefilled dialogs.
Validation before editing:
Fires in production source or config/CI files on four shapes: (1) a redirect(...) call whose argument is attacker-controllable caller input: a bare identifier/property referencing searchParams.get/nextUrl.searchParams/returnTo/callbackUrl/continue/next (open redirect); (2) an <iframe> whose markup within ~700 chars carries redirect/URL-param shapes like next=/continue=/redirect=/redirect_uri/role=/..; (3) a frame-ancestors * (or 'self' *) CSP; or (4) an X-Frame-Options: ALLOW… header. Comments are stripped first.
Suppress when: already exempted: a redirect keyword that appears only inside a string literal (e.g. redirect('/login?...continue...')) and a target already passed through a safe*/valid*/sanitiz*/allowlist/whitelist helper are skipped; a remaining FP is a next/returnTo value already validated against a same-origin or path allowlist before this redirect().
Constraints:
- Make the smallest change that fixes the root cause.
- Preserve behavior and interfaces unrelated to this diagnostic.
- Reuse existing project components, utilities, and conventions.
- Keep validation and authorization on trusted boundaries. Do not replace them with client-only checks.
- Adapt identifiers and framework details instead of copying blindly.
- Do not disable the rule or suppress matching code.
- Confirm this rule is enabled for the project:
production source files (.js/.ts/.tsx) or config/CI files; tests/build/docs/generated paths skipped.
Assessment:
- Record detector evidence, applicability facts, assumptions, missing evidence, and the rule class for this occurrence.
- Return one outcome: Confirmed failure, Rejected, Needs evidence, Unavailable, Waived with evidence, or Observation.
- A waiver records the established failure, scope, authority, evidence, and review or expiry condition. It is not a pass or false positive.
Verification:
- Run focused tests for the changed behavior.
- Run React Doctor and confirm this diagnostic no longer appears from changed code.
- Run an unfiltered scan of the affected scope before claiming no cross-category regression.
- Report the files changed and any checks you could not run.