-
Notifications
You must be signed in to change notification settings - Fork 0
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
added vuln #2
base: main
Are you sure you want to change the base?
added vuln #2
Conversation
|
||
username = form.get('username') | ||
password = form.get('password') | ||
password_hash = _hash_password(password) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like MD5 is used as a password hash. MD5 is not considered a secure password hash because it can be cracked by an attacker in a short amount of time. Use a suitable password hashing function such as scrypt. You can use hashlib.scrypt
.
View Dataflow Graph
flowchart LR
classDef invis fill:white, stroke: none
classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none
subgraph File0["<b>vulns/sql_injection/sql_injection_login.py</b>"]
direction LR
%% Source
subgraph Source
direction LR
v0["<a href=https://github.com/atearjen/bad-python-app/blob/c06419049f5f898135eeba1c65309a15071249a7/vulns/sql_injection/sql_injection_login.py#L109 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 109] hashlib.md5</a>"]
end
%% Intermediate
subgraph Traces0[Traces]
direction TB
v2["<a href=https://github.com/atearjen/bad-python-app/blob/c06419049f5f898135eeba1c65309a15071249a7/vulns/sql_injection/sql_injection_login.py#L109 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 109] md5_pass</a>"]
v3["<a href=https://github.com/atearjen/bad-python-app/blob/c06419049f5f898135eeba1c65309a15071249a7/vulns/sql_injection/sql_injection_login.py#L81 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 81] _hash_password</a>"]
end
v2 --> v3
%% Sink
subgraph Sink
direction LR
v1["<a href=https://github.com/atearjen/bad-python-app/blob/c06419049f5f898135eeba1c65309a15071249a7/vulns/sql_injection/sql_injection_login.py#L81 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 81] _hash_password(password)</a>"]
end
end
%% Class Assignment
Source:::invis
Sink:::invis
Traces0:::invis
File0:::invis
%% Connections
Source --> Traces0
Traces0 --> Sink
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/semgrep ignore not relevant
password_hash = _hash_password(password) | ||
|
||
sql = f"SELECT * FROM users WHERE username='{username}' AND password='{password_hash}'" | ||
flask.render_template_string(username) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found a template created with string formatting. This is susceptible to server-side template injection and cross-site scripting attacks.
Ignore this finding from render-template-string.password = form.get('password') | ||
password_hash = _hash_password(password) | ||
|
||
sql = f"SELECT * FROM users WHERE username='{username}' AND password='{password_hash}'" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Detected user input used to manually construct a SQL string. This is usually bad practice because manual construction could accidentally result in a SQL injection. An attacker could use a SQL injection to steal or modify contents of the database. Instead, use a parameterized query which is available by default in most database engines. Alternatively, consider using the Django object-relational mappers (ORM) instead of raw SQL queries.
View Dataflow Graph
flowchart LR
classDef invis fill:white, stroke: none
classDef default fill:#e7f5ff, color:#1c7fd6, stroke: none
subgraph File0["<b>vulns/sql_injection/sql_injection_login.py</b>"]
direction LR
%% Source
subgraph Source
direction LR
v0["<a href=https://github.com/atearjen/bad-python-app/blob/c06419049f5f898135eeba1c65309a15071249a7/vulns/sql_injection/sql_injection_login.py#L77 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 77] request.form</a>"]
end
%% Intermediate
subgraph Traces0[Traces]
direction TB
v2["<a href=https://github.com/atearjen/bad-python-app/blob/c06419049f5f898135eeba1c65309a15071249a7/vulns/sql_injection/sql_injection_login.py#L77 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 77] form</a>"]
v3["<a href=https://github.com/atearjen/bad-python-app/blob/c06419049f5f898135eeba1c65309a15071249a7/vulns/sql_injection/sql_injection_login.py#L79 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 79] username</a>"]
end
v2 --> v3
%% Sink
subgraph Sink
direction LR
v1["<a href=https://github.com/atearjen/bad-python-app/blob/c06419049f5f898135eeba1c65309a15071249a7/vulns/sql_injection/sql_injection_login.py#L83 target=_blank style='text-decoration:none; color:#1c7fd6'>[Line: 83] f"SELECT * FROM users WHERE username='{username}' AND password='{password_hash}'"</a>"]
end
end
%% Class Assignment
Source:::invis
Sink:::invis
Traces0:::invis
File0:::invis
%% Connections
Source --> Traces0
Traces0 --> Sink
No description provided.