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

don't taint the result of most binary operations #6809

Merged
merged 3 commits into from
Nov 4, 2021

Conversation

orklah
Copy link
Collaborator

@orklah orklah commented Nov 3, 2021

As far as I can tell, only Concat and Coalesce binary ops can pass taint to the result.

To whoever it may concern: this method is called for other Expr, there are other Expr that does not imply tainted results (I'm thinking PostInc for example: https://psalm.dev/r/4e6d6d9566). If someone want to give a hand and list all Expr that could and couldn't pass taint, it would be most helpful and I'd gladly amend this to add them all.

This will fix #6804

@psalm-github-bot
Copy link

I found these snippets:

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

$input = $_GET['foo'];
$var = $input++;
var_dump($var);
Psalm output (using commit edb7655):

ERROR: TaintedHtml - 5:10 - Detected tainted HTML

@orklah orklah added the release:fix The PR will be included in 'Fixes' section of the release notes label Nov 3, 2021
@weirdan
Copy link
Collaborator

weirdan commented Nov 3, 2021

As far as I can tell, only Concat and Coalesce binary ops can pass taint to the result.

What about + used on arrays (https://www.php.net/manual/en/language.operators.array.php)?

@orklah
Copy link
Collaborator Author

orklah commented Nov 3, 2021

Nice catch, I'll fix that

@orklah orklah merged commit e6dccaa into vimeo:master Nov 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release:fix The PR will be included in 'Fixes' section of the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bool comparison should remove tainted input from result
2 participants