Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tainting with filter_vars and array_map #3675

Closed
thbley opened this issue Jun 25, 2020 · 5 comments
Closed

Tainting with filter_vars and array_map #3675

thbley opened this issue Jun 25, 2020 · 5 comments
Labels

Comments

@thbley
Copy link
Contributor

thbley commented Jun 25, 2020

<?php

$get = $_GET;

echo $get["test"];

gives an error (OK):
ERROR: TaintedInput - src/index.php:5:6 - Detected tainted html in path: $_GET -> $get (src/index.php:3:1) -> $get['test'] (src/index.php:5:6) -> call to echo (src/index.php:5:6) -> echo#1 (see https://psalm.dev/205)
echo $get["test"];

<?php

$get = array_map('trim', $_GET);

echo $get["test"];

gives no tainting error (FAIL)

version used: psalm 3.12.1

@psalm-github-bot
Copy link

Hey @thomasbley, can you reproduce the issue on https://psalm.dev ?

@thbley
Copy link
Contributor Author

thbley commented Jun 25, 2020

can you reproduce the issue on https://psalm.dev ?

No, seems taint-analysis is not enabled there and settings have no option to enable it.

@thbley
Copy link
Contributor Author

thbley commented Jun 25, 2020

also:

<?php

$get = filter_var($_GET, FILTER_CALLBACK, ['options' => 'trim']);

echo $get["test"];

gives no tainting error (FAIL)

@muglug muglug added the bug label Jun 25, 2020
@muglug
Copy link
Collaborator

muglug commented Jun 25, 2020

FYI you can append a comment to the header on psalm.dev: https://psalm.dev/r/cb40a74129

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/cb40a74129
<?php // --taint-analysis

$get = array_map('trim', $_GET);

echo $get["test"];
Psalm output (using commit f458959):

No issues!

@muglug muglug closed this as completed in 9837a60 Jun 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants