DSN netloc substring matching misclassifies unrelated destinations as SDK-internal
@YusefSyed arbeitet bereits daran.
Seit 04.9.2026.
Bewertung
Dieses Issue wurde noch nicht bewertet.
Beschreibung
How do you use Sentry?
Sentry Saas (sentry.io)
Version
2.68.1 (latest release; also reproduced on current master)
Steps to Reproduce
sentry_sdk.utils.is_sentry_url() currently classifies a candidate using:
client.transport.parsed_dsn.netloc in url
This reproduction uses the installed SDK and makes no network requests:
from http.client import HTTPConnection
from sentry_sdk.client import Client
from sentry_sdk.tracing_utils import should_propagate_trace
from sentry_sdk.utils import is_sentry_url
client = Client(
dsn="https://key@abcd1234.ingest.sentry.io/1",
trace_propagation_targets=[".*"],
default_integrations=False,
)
cases = [
(
"hostname suffix",
"https://abcd1234.ingest.sentry.io.evil.test/api/1",
False,
),
(
"userinfo",
"https://abcd1234.ingest.sentry.io@attacker.test/api/1",
False,
),
(
"query",
"https://attacker.test/?next=abcd1234.ingest.sentry.io",
False,
),
(
"case-only real host",
"https://ABCD1234.INGEST.SENTRY.IO/api/1/envelope/",
True,
),
]
for label, url, expected in cases:
print(
label,
expected,
is_sentry_url(client, url),
should_propagate_trace(client, url),
)
custom_port_client = Client(
dsn="http://key@localhost:9000/1",
default_integrations=False,
)
connection = HTTPConnection("localhost", 9000)
print(
"custom-port raw host",
True,
is_sentry_url(custom_port_client, connection.host),
)
Current output (expected, actual, should_propagate_trace) is:
hostname suffix False True False
userinfo False True False
query False True False
case-only real host True False True
custom-port raw host True False
The same behavior reproduces in sentry-sdk==2.68.1 and current master at
0aa3f2bd4a27f40c7e828cb0f6f92bcf677df852. The focused existing suites remain
green (3 classifier tests and 16 trace-target tests), but do not cover these
boundaries.
Expected Result
Internal-request classification should depend on the candidate's actual
hostname, not an arbitrary occurrence of DSN text.
Proposed narrow contract for maintainer confirmation:
- compare the candidate hostname with the DSN hostname using case-insensitive
exact equality; - support both absolute URLs and raw-host input;
- preserve the current scheme-independent behavior;
- exclude port from identity for this focused change;
- do not include child subdomains by default; and
- return
False, without raising, when a hostname cannot be safely obtained.
This deliberately leaves same-host/different-port requests classified as
internal. Would this focused contract be acceptable? I will wait for a
maintainer response before implementing anything and will follow a different
port or subdomain contract if requested.
Actual Result
The substring comparison produces seven false positives and two false negatives
in the extended standalone matrix. The additional cases cover an embedded
hostname, path text, a raw-host suffix, and a neighboring IPv6 literal.
The common verified downstream effect is suppression of otherwise configured
sentry-trace and baggage headers for an unrelated destination. In the
stdlib raw-host path, a lookalike host can also take the early return that skips
the outgoing HTTP span and breadcrumb path. Conversely, a case-only real host
or the raw host of a custom-port DSN is not recognized as internal.
This is an instrumentation-correctness report. I have not demonstrated traffic
redirection, credential disclosure, account takeover, or another security
exploit. I found no matching public Sentry Python issue or open pull request in
bounded symbol and behavior searches.
- Vorherrschende Sprache
- Python
- Sterne
- 2.2k
- Forks
- 672
- Ø Merge
- 22 Std. 47 Min.
- Gemergte PRs (30 T.)
- 224
Beitragsleitfaden
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus getsentry/sentry-python
-
Python
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
getsentry/sentry-python#7569 · 1 Kommentar ·
-
Python
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
getsentry/sentry-python#7568 · 2 Kommentare ·
-
Python
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
getsentry/sentry-python#7567 · 1 Kommentar ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
getsentry/sentry-python#7543 · 2 Kommentare · 1 zugewiesene Person ·
-
Python
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
getsentry/sentry-python#6992 · 1 Kommentar ·
Alle Issues in getsentry/sentry-python
Ähnliche Issues
-
essnmx good first issue
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 95/100
-
[Feature] 奇物选择添加优先级 Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 65/100
syfoud/Simulated_Scepter#174 ·
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
Giskard-AI/giskard-oss#2840 · 1 Kommentar ·
-
A claim comment carrying the issue number is silently declined while the workflow reports success Offenarea: repo bug perceived difficulty: 2
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
yeti-platform/yeti#1380 ·