-
Notifications
You must be signed in to change notification settings - Fork 230
Add timeout to requests calls
#66
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,7 +68,7 @@ | |
| try: | ||
| # Use lxml to parse the XML data | ||
| parser = etree.XMLParser(load_dtd=True, resolve_entities=True) | ||
| tree = etree.fromstring(xml_data.encode(), parser) | ||
| output = f"Parsed XML: {etree.tostring(tree, encoding='unicode')}" | ||
| except Exception as e: | ||
| output = f"XML Parsing Error: {e}" | ||
|
|
@@ -77,7 +77,7 @@ | |
| elif 'url' in request.form: | ||
| url = request.form['url'] | ||
| try: | ||
| response = requests.get(url) | ||
| response = requests.get(url, timeout=60) | ||
|
||
| output = f"SSRF Response: {response.text[:200]}" | ||
| except Exception as e: | ||
| output = f"SSRF Error: {e}" | ||
|
|
||
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
Server-Side Request Forgery (Ssrf) Risk With User Data In Requests In Django
Data from request object is passed to a new server-side request. This could lead to a server-side request forgery (SSRF). To mitigate, ensure that schemes and hosts are validated against an allowlist, do not forward the response to the user, and ensure proper authentication and transport-layer security in the proxied request. See https://owasp.org/www-community/attacks/Server_Side_Request_Forgery to learn more about SSRF vulnerabilities.
Severity: HIGH
Learn more about this issue
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
This remediation will modify the vulnerable request call in your code to validate the target URL before making a request. This helps prevent server-side request forgery (SSRF) attacks by ensuring that only allowed URLs are used.
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 "Server-Side Request Forgery (SSRF) risk with user data in requests in Django" in insecure-app/app.py; future occurrences will also be ignored.#jit_undo_ignoreUndo ignore command