[Bug]: Incomplete URL substring sanitization Unvalidated Redirects and Forwards
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 45/100
Direzione di ricerca
Inizia da tests/integration/domains/test_slave_domains.py alla riga 73 e segui la gestione degli URL che verifica. Controlla se la validazione dell’host si basa sulla corrispondenza di sottostringhe, quindi esegui il test di integrazione pertinente. Il lavoro è concluso quando prefissi arbitrari del nome host o testo incorporato relativo a un host consentito non superano più la validazione, mentre gli host consentiti legittimi continuano a funzionare.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
CLI Version
v5.56.2
Command
Sanitizing untrusted URLs is a common technique for preventing attacks such as request forgeries and malicious redirections. Usually, this is done by checking that the host of a URL is in a set of allowed hosts. However, treating the URL as a string and checking if one of the allowed hosts is a substring of the URL is very prone to errors. Malicious URLs can bypass such security checks by embedding one of the allowed hosts in an unexpected location.
Even if the substring check is not used in a security-critical context, the incomplete check may still cause undesirable behaviors when the check succeeds accidentally.
Output
No response
Expected Behavior
Recommendation
Parse a URL before performing a check on its host value, and ensure that the check handles arbitrary subdomain sequences correctly.
Actual Behavior
CWE-20
Steps to Reproduce
POC
The following code checks that a URL redirection will reach the example.com domain.
from flask import Flask, request, redirect
from urllib.parse import urlparse
app = Flask(__name__)
# Not safe, as "evil-example.net/example.com" would be accepted
@app.route('/some/path/bad1')
def unsafe1(request):
target = request.args.get('target', '')
if "example.com" in target:
return redirect(target)
# Not safe, as "benign-looking-prefix-example.com" would be accepted
@app.route('/some/path/bad2')
def unsafe2(request):
target = request.args.get('target', '')
if target.endswith("example.com"):
return redirect(target)
#Simplest and safest approach is to use an allowlist
@app.route('/some/path/good1')
def safe1(request):
allowlist = [
"example.com/home",
"example.com/login",
]
target = request.args.get('target', '')
if target in allowlist:
return redirect(target)
#More complex example allowing sub-domains.
@app.route('/some/path/good2')
def safe2(request):
target = request.args.get('target', '')
host = urlparse(target).hostname
#Note the '.' preceding example.com
if host and host.endswith(".example.com"):
return redirect(target)
The first two examples show unsafe checks that are easily bypassed. In unsafe1 the attacker can simply add example.com anywhere in the url. For example, http://evil-example.net/example.com. In unsafe2 the attacker must use a hostname ending in example.com, but that is easy to do. For example, http://benign-looking-prefix-example.com.
The second two examples show safe checks. In safe1, an allowlist is used. Although fairly inflexible, this is easy to get right and is most likely to be safe. In safe2, urlparse is used to parse the URL, then the hostname is checked to make sure it ends with .example.com.
References
SSRF
XSS Unvalidated Redirects and Forwards Cheat Sheet.
CWE-20.
- Lingua principale
- Python
- Stelle
- 442
- Fork
- 159
- Merge medio
- 7g 21h
- PR unite (30g)
- 8
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di linode/linode-cli
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
linode/linode-cli#894 ·
-
enhancement
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
linode/linode-cli#859 · 1 commento ·
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
linode/linode-cli#868 ·
-
bug
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
linode/linode-cli#825 · 1 commento ·
-
enhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
linode/linode-cli#788 ·
Tutte le issue di linode/linode-cli
Issue simili
-
triage/confirmed
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
agentscope-ai/agentscope#2775 ·
-
comp/desktop P3 type/bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 92/100
NousResearch/hermes-agent#118866 ·
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
apache/cloudstack#14222 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100