-
Notifications
You must be signed in to change notification settings - Fork 230
create insecure-api #63
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
Conversation
DryRun Security SummaryThe changes in this GitHub Pull Request introduce a range of updates to an intentionally insecure API application, including vulnerabilities such as broken object-level authorization, broken authentication, excessive data exposure, security misconfiguration, lack of rate limiting, mass assignment, SQL injection, and improper asset management, which are designed for educational purposes to demonstrate various API security vulnerabilities outlined in the OWASP API Security Top 10. Expand for full summarySummary: The changes in this GitHub Pull Request cover a range of updates to an intentionally insecure API application, as well as changes to the associated Docker image and configuration files. The key points from an application security perspective are:
Overall, the changes in this Pull Request are focused on maintaining an intentionally insecure API application for educational and demonstration purposes. As an application security engineer, it's important to review these changes carefully to understand the security implications and ensure that the application is not deployed in a way that could compromise the security of the overall system. Files Changed:
Code AnalysisWe ran
|
|
New dependencies detected. Learn more about Socket for GitHub ↗︎
|
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.
❌ Jit has detected 2 important findings in this PR that you should review.
The findings are detailed below as separate comments.
It’s highly recommended that you fix these security issues before merge.
| cursor = conn.cursor() | ||
| # BAD: Directly inserting user input into SQL query without sanitization | ||
| sql_query = f"SELECT * FROM video_games WHERE title LIKE '%{query}%'" | ||
| cursor.execute(sql_query) |
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.
Security control: Static Code Analysis Python Semgrep
Type: Sqlalchemy Raw Sql Query Concatenation Risks Sql Injection
Description: Avoiding SQL string concatenation: untrusted input concatenated with raw SQL query can result in SQL Injection. In order to execute raw query safely, prepared statement should be used. SQLAlchemy provides TextualSQL to easily used prepared statement with named parameters. For complex SQL composition, use SQL Expression Language or Schema Definition Language. In most cases, SQLAlchemy ORM will be a better option.
Severity: HIGH
Jit Bot commands and options (e.g., ignore issue)
You can trigger Jit actions by commenting on this PR review:
#jit_ignore_fpIgnore and mark this specific single instance of finding as “False Positive”#jit_ignore_acceptIgnore and mark this specific single instance of finding as “Accept Risk”#jit_ignore_type_in_fileIgnore any finding of type "SQLAlchemy raw SQL query concatenation risks SQL Injection" in insecure-api/main.py; future occurrences will also be ignored.#jit_undo_ignoreUndo ignore command
| @@ -0,0 +1,21 @@ | |||
| # Use an official Python runtime as a parent image | |||
| FROM python:3.9-slim | |||
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.
Security control: Docker Scan
Type: Image User Should Not Be 'Root'
Description: Running containers with 'root' user can lead to a container escape situation. It is a best practice to run containers as non-root users, which can be done by adding a 'USER' statement to the Dockerfile.
Severity: HIGH
Fix suggestion:
This fix suggestion was generated by Jit. Please note that the suggestion might not always fit every use case. It is highly recommended that you check and review it before merging.
Suggestion guidelines
- First of all, check if your container is running as a root user. In most of the cases, you can do it by running a command like this:
docker run <image> whoami. If it returnsroot, then you should consider using a non-root user, by following one of the next steps:- If a non-root user already exists in your container, consider using it.
- If not, you can create a new user by adding a
USERcommand to the Dockerfile, with a non-root user as argument, for example:USER <non-root-user-name>.
| FROM python:3.9-slim | |
| FROM python:3.9-slim | |
| RUN addgroup --system <group> | |
| RUN adduser --system <user> --ingroup <group> | |
| USER <user>:<group> | |
Jit Bot commands and options (e.g., ignore issue)
You can trigger Jit actions by commenting on this PR review:
#jit_ignore_fpIgnore and mark this specific single instance of finding as “False Positive”#jit_ignore_acceptIgnore and mark this specific single instance of finding as “Accept Risk”#jit_ignore_type_in_fileIgnore any finding of type "Image user should not be 'root'" in insecure-api/Dockerfile; future occurrences will also be ignored.#jit_undo_ignoreUndo ignore command
No description provided.