Why it matters
A "javascript:" value runs script when the user clicks or the frame loads.
How to fix it
Parse the value with new URL() and allow only http: and https: schemes (or only relative paths) before rendering it.
Example
The rule's own test fixtures, verbatim: the test suite requires the rule to report the first and not the second.
"use client";
import { useSearchParams } from "next/navigation";
export function BackLink() {
const params = useSearchParams();
return <a href={params.get("back")}>Back</a>;
}"use client";
import { useSearchParams } from "next/navigation";
export function BackLink() {
const params = useSearchParams();
const back = params.get("back");
return <a href="/dashboard">Back {back ? "" : ""}</a>;
}What TrustIvan reads
Runs on repository scans of TypeScript source once static analysis is turned on (SAST_RULES and the separately built analyzer image); it is off by default.
Weakness classes and references
Related checks
- Regex injection from request input (TypeScript)
TypeScriptSeverity: Medium
trustivan-typescript-taint-regex-injection - SQL template literal (TypeScript)
TypeScriptSeverity: Medium
trustivan-typescript-sql-template-literal - Prototype pollution from request input (TypeScript)
TypeScriptSeverity: High
trustivan-typescript-taint-prototype-pollution - Next.js public secret (TypeScript)
TypeScriptSeverity: High
trustivan-typescript-next-public-secret - NoSQL injection from request input (TypeScript)
TypeScriptSeverity: High
trustivan-typescript-taint-nosql-injection - Next.js image any host (TypeScript)
TypeScriptSeverity: Medium
trustivan-typescript-next-image-any-host
Terms: SAST (static application security testing), Taint analysis, CWE (Common Weakness Enumeration), OWASP Top 10
All static analysis (SAST) checks · The whole catalogue · How this works in TrustIvan · Documentation