question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Running python with optimizations makes UsernamePasswordMako accept any password for any user

See original GitHub issue

On the current master branch, the UsernamePasswordMako class relies on an assert statement to check the user’s password: https://github.com/rohe/pysaml2/blob/9cbbd9bd9f6bfa5e9ceace064dd1af4e2ff2f68c/src/saml2/authn.py#L149

The assert is supposed to raise an exception if the password doesn’t match. This is insecure: running python with optimizations enabled (either via the -O or -OO flags, or with the PYTHONOPTIMIZE environment variable) will remove all such assertions. This means that no exception will be raised on an incorrect password, and the UsernamePasswordMako will accept any password for any user.

It would be better to have an explicit check that raises an exception to avoid this problem.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:78
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
rohecommented, Jan 15, 2018

I’ll go through the code and replace all assert statements with if statements.

5reactions
obi1kenobicommented, Nov 25, 2017

In my opinion, it would be better to leave this as a breaking change and signal that through semver. Raising AssertionError to indicate authentication failure seems unintuitive at best, and we’re better off without it IMHO.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Alec Muffett on Twitter: "Oh, this is glorious: pysaml2 library ...
Running python with optimizations makes UsernamePasswordMako accept any password for any user ·... On the current master branch, ...
Read more >
3. Configure Python — Python 3.11.1 documentation
You can use the configure --enable-optimizations option to make this the default target of the make command ( make all or just make...
Read more >
I need to securely store a username and password in Python ...
Basically do the following: Use file system permissions (chmod 400) Strong password for owner's account on the system.
Read more >
SPID e Webserver Embedded Twisted Python - Forum Italia
Issue: Running python with optimizations makes UsernamePasswordMako accept any password for any user. opened by obi1kenobi on 2017-09-09.
Read more >
Assisting Provet Cloud Users With Speech Recognition ...
The biggest learning takeaway for me is all new technology ... 31 Running python with optimizations makes UsernamePasswordMako accept any.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found