Request input is printed into the page without escaping
What it finds
echo $_GET['name'] and <?= $_POST['q'] ?>: printing what the request sent without escaping lets the sender put HTML and scripts into the page, which run in the browser of whoever views it. echo, print, <?=, printf and print_r are checked; escape with htmlspecialchars or the template's escaping function.
From the rule's source, echo_request_input.rs.
<?phpfunction greet(){ echo 'Hello ' . $_GET['name'];tx0 reports: request input from $_GET reaches the page echo htmlspecialchars($_GET['name']); print $_SERVER['PHP_SELF'];tx0 reports: request input from $_SERVER['PHP_SELF'] reaches the page echo $_SERVER['DOCUMENT_ROOT']; $q = $_REQUEST['q'] ?? ''; echo "You searched for $q";tx0 reports: request input from $_REQUEST reaches the page echo intval($_GET['n']);}?><p><?= $_POST['comment'] ?></p>tx0 reports: request input from $_POST reaches the page Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/php:echo-request-input" = "error"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/php:echo-request-input] reason="..."tx0 explain tx0/php:echo-request-input shows the same in the terminal. Found a false positive? Report it.