Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

list is tainted by calling list.append(TAINT) #181

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

Merged
bcaller merged 1 commit into python-security:master from bcaller:appendaddextendinsert
Nov 1, 2018

Conversation

@bcaller
Copy link
Collaborator

@bcaller bcaller commented Oct 31, 2018

Taint is propagated by:

list += [TAINT]
list = list + TAINT

but with lists we often use a function to mutate the list:

list = []
list.append(TAINT)
list.insert(0, TAINT)
list.extend(TAINT)

Previously this didn't taint list so we had FALSE NEGATIVES.

Now list.append(TAINT) is treated like augmented assignment, so list
will be tainted.

list += list.append(TAINT)

Of course this wouldn't work as real code since append returns None
but it is how you can think about this function which mutates list.

The same goes for set.add(), list.extend(), list.insert(),
dict.update(), although we aren't actually doing type checking, just
looking at the name of the method.

KevinHock reacted with thumbs up emoji KevinHock reacted with hooray emoji KevinHock reacted with heart emoji
@KevinHock KevinHock self-requested a review October 31, 2018 18:19
Copy link
Collaborator

@KevinHock KevinHock left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is really great :D

else:
raise Exception('Definition was neither FunctionDef or ' +
'ClassDef, cannot add the function ')
elif (
Copy link
Collaborator

@KevinHock KevinHock Nov 1, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lovely elif

Taint is propagated by:
```
list += [TAINT]
list = list + TAINT
```
but with lists we often use a function to mutate the list:
```
list = []
list.append(TAINT)
list.insert(0, TAINT)
list.extend(TAINT)
```
Previously this didn't taint `list` so we had FALSE NEGATIVES.
Now `list.append(TAINT)` is treated like augmented assignment, so list
will be tainted.
`list += list.append(TAINT)`
Of course this wouldn't work as real code since `append` returns `None`
but it is how you can think about this function which mutates `list`.
The same goes for `set.add()`, `list.extend()`, `list.insert()`,
`dict.update()`, although we aren't actually doing type checking, just
looking at the name of the method.
@bcaller bcaller merged commit 79d39d8 into python-security:master Nov 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@KevinHock KevinHock KevinHock approved these changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /