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

Possibility to detect taint in array keys #5470

Closed
ohader opened this issue Mar 24, 2021 · 4 comments
Closed

Possibility to detect taint in array keys #5470

ohader opened this issue Mar 24, 2021 · 4 comments
Labels

Comments

@ohader
Copy link
Contributor

ohader commented Mar 24, 2021

https://psalm.dev/r/e6853c1780

doTheMagic([(string)$_GET['injected'] => 'value']);

Array keys being composed by user-submitted content are not considered tainted.

@psalm-github-bot
Copy link

I found these snippets:

https://psalm.dev/r/e6853c1780
<?php // --taint-analysis
/**
 * @param array<string, string> $values
 * @psalm-taint-sink html $values
 */
function doTheMagic(array $values) {}

// detected
doTheMagic(['value' => (string)$_GET['injected']]);
// not detected
doTheMagic([(string)$_GET['injected'] => 'value']);
Psalm output (using commit efa9b13):

ERROR: TaintedHtml - 6:27 - Detected tainted HTML

@ohader
Copy link
Contributor Author

ohader commented Mar 24, 2021

I've spotted a bunch of array-related PRs (e.g. #5444), Sam @mortenson did you accidentally stumble over similar scenarios as well?

@muglug muglug added the bug label Mar 24, 2021
@mortenson
Copy link
Contributor

@ohader No - I haven't seen this before, and didn't think of it when tweaking ArrayAnalyzer.

@muglug muglug closed this as completed in 10ccbdd Mar 24, 2021
@ohader
Copy link
Contributor Author

ohader commented Mar 24, 2021

❤️ awesome, thx @muglug

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

3 participants