mirror of
https://github.com/github/codeql.git
synced 2025-12-18 18:10:39 +01:00
I've added 2 queries: - one that detects full SSRF, where an attacker can control the full URL, which is always bad - and one for partial SSRF, where an attacker can control parts of an URL (such as the path, query parameters, or fragment), which is not a big problem in many cases (but might still be exploitable) full SSRF should run by default, and partial SSRF should not (but makes it easy to see the other results). Some elements of the full SSRF queries needs a bit more polishing, like being able to detect `"https://" + user_input` is in fact controlling the full URL.
12 lines
351 B
Python
12 lines
351 B
Python
from flask import request
|
|
|
|
import requests
|
|
|
|
def ssrf_test():
|
|
user_input = request.args['untrusted_input']
|
|
|
|
requests.get(user_input) # NOT OK -- user has full control
|
|
|
|
# since `requests`` always uses complete URLs, it's not interesting to test more of
|
|
# the framework directly. See `full_partial_test.py` for different ways to do SSRF.
|