Repository navigation
Closed
Labels
priority/p1-highPriority P1: high-impact work for the next planned milestonescope/aiAI review pipeline, personas, prompts, LLM client, or RAGscope/securitySecurity linters (trivy, bandit, gitleaks, kubeconform) and Vaultscope/telemetryOpenTelemetry tracing spans, Prometheus metrics, and Jaegertype/securityType security: a vulnerability or a leak
Milestone
Description
Problem
Lines cited at dcafadf.
At 132ecc5, config/constants.py:2222 is :2223; no other cited line moved.
Credentials in URLs are masked by hand-written string code in four places. Each one leaks or breaks something that urllib.parse and httpx2 already handle. Every result below comes from an offline probe against httpx2 2.13.0 at dcafadf.
- Exception details keep part of the password.
SSRFBlockedError(exceptions/security.py:40-53) finds the host withnetloc.partition("@"), which splits at the first '@'. urllib and httpx2 split userinfo at the last '@'.SSRFBlockedError("http://u:p@[email protected]/x").details["target_url"]ishttp://<auth>@[email protected]/x. That is the value after the base class has masked it.- For
http://169.254.169.254:abc/, the constructor itself raises a plainValueError("Port could not be cast to integer value as 'abc'"), so the refusal is never built.
- The URL masker drops IPv6 brackets.
mask_uri_credentials(security/sanitizer.py:288-307) rebuilds the authority fromhostnamewith an f-string.http://u:pw@[2001:db8::1]:8080/pcomes out ashttp://u:***@2001:db8::1:8080/p, which no parser can read back.- Its regex fallback (:302-307) is the only reason some passwords are masked today.
mysql://root:pa/[email protected]/xandmysql://root:12/[email protected]/xboth come out asmysql://root:***@example.com/x, andhttp://u:1234#[email protected]/ashttp://u:***@example.com/.
- The telemetry endpoint masking is wrong in two ways.
sanitize_telemetry_endpoint(sanitizer.py:343-366):- turns
http://[::1]:4318intohttp://::1:4318; - leaves
http://100.64.1.2:4318unmasked, because 100.64.0.0/10 is neitheris_privatenoris_loopback; - matches loopback against a string tuple (:352).
- turns
- The free-text redactor only handles http and https. This is the URL entry of
redact_text's pattern table (sanitizer.py:235-239),https?://[^:/\s@]+:[^@/\s?#]+@.- It leaves what follows the first '@':
https://u:p@[email protected]/xbecomeshttps://<masked-user>:<masked-password>@[email protected]/x. - It rewrites every
http://URL it masks ashttps://. - It leaves these unmasked:
postgres://app:s3cret@…,redis://:pw@…, uppercaseHTTP://U:PW@…, empty-usernamehttp://:secret@…,http://u:pa#ss@…andmysql://root:pa/ss@…. - Every
DevOpsCLIErrormessage and its details pass throughredact_text(exceptions/base.py:10-16, :37-44). So do review diffs before they reach the model (ai/review/runner.py:1399, :1741, :1921, :1970).
- It leaves what follows the first '@':
- Two call sites pass free text to the URL masker. argo/gitops.py:399 (
mask_secrets(mask_uri_credentials(str(exc)))) and sandbox/metrics.py:446 (redact_text(mask_uri_credentials(str(exc)))) both hand an exception message to the single-URL masker. A URL parser finds no userinfo in a sentence, so these calls must rely on the free-text redactor alone. - served_by is stored as received. It is LiteLLM's
x-litellm-model-api-basereply header (config/constants.py:2222). Its only readers today are ai/client/openai.py:175 and :205. It goes unmasked into:- the spend ledger (ai/spend/ledger.py:659-674), which groups by it at :164-165;
- the call observers (ledger.py:677-691);
- the event payload (ai/client/unified.py:124-125);
- the
llm.served_byspan attribute (unified.py:140-141). Span attributes are stored exactly as passed in (telemetry/tracer.py:362-364, :1033).
- The Vault address is recorded as given. security/vault_broker.py:170-171 puts
vault_addron thesecurity.vault_broker.get_statusspan, and the debug logs at :122 and :162 print URLs built from it. The address comes fromVAULT_ADDR, and nothing rejects userinfo in it (:71-88). - A pass-through wrapper.
_sanitize_telemetry_endpoint(server/routes/telemetry.py:21-23) only callssanitize_telemetry_endpoint. The no-shims rule (AGENTS.md:91) forbids such wrappers. Two test files import it.
The replacement uses library parsers only. One fixed placeholder, <masked-url>, stands for any whole value that is replaced because it cannot be parsed safely.
- Single URLs (
mask_uri_credentials,SSRFBlockedError, the Vault span and logs) are parsed withhttpx2.URL. httpx2 2.13.0 is a direct, exact-pinned dependency (pyproject.toml:19), and it is the parser of the client that sends.- Fail closed. Return
<masked-url>, never the input, in two cases:- httpx2 raises
httpx2.InvalidURL. It raisesInvalid port: 'pa'onmysql://root:pa/[email protected]/xandhttp://u:pa#[email protected]/. - httpx2 finds no userinfo, but the input contains '@'. A password that starts with digits and contains '/', '?' or '#' parses as a port without error:
mysql://root:12/[email protected]/xgives hostrootand port 12, andhttp://u:1234#[email protected]/gives hostuand port 1234. A password that starts with '/', '?' or '#' (http://u:/[email protected]/) gives hostu. - Today's regex fallback masks all five. Returning the input in either case would leak passwords that are masked today.
- The second case also catches a URL with '@' only in its path or query. Key question 7 weighs that cost.
- httpx2 raises
- Rewrite only when there is a password (
u.passwordis not empty). Useu.copy_with(username=u.username, password="***"). For an empty username,copy_with(username="***", password=None)gives thehttp://***@…that tests pin. Pass both arguments:copy_with(password="***")alone drops the username. A lone username follows key question 1. - Use a URL-safe placeholder,
***. httpx2 percent-encodes<auth>as%3Cauth%3E. - SSRFBlockedError masks
target_urlbefore cutting it to 256 characters. Itspartition("@")and_replace(netloc=…)code is deleted.- Its message keeps today's text, for example
SSRF blocked: http://<masked>:8000/api (reason)forhttp://192.0.2.1:8000/api, with scheme, port and path taken from the same httpx2 parse. - The message is display text, not a URL, so
<masked>is inserted as text. Building it through httpx2 (copy_with(host="<masked>")) giveshttp://%3Cmasked%3E:8000/api, which fails tests/test_exceptions.py:48 ("<masked>" in str(err)). - A target that fails closed gives
target_url<masked-url>and the messageSSRF blocked: <masked-url> (reason).
- Its message keeps today's text, for example
- Fail closed. Return
- Free text (the URL entry of
redact_text; the pattern table already accepts a callable replacement):- Finding candidates. A candidate starts at a scheme in RFC 3986's grammar (section 3.1), capped at 32 characters:
[A-Za-z][A-Za-z0-9+.-]{0,31}://. It runs until whitespace or until the next scheme start, so everyscheme://begins its own candidate. One pattern does both:[A-Za-z][A-Za-z0-9+.-]{0,31}://(?:(?![A-Za-z][A-Za-z0-9+.-]{0,31}://)\S)*.- Why stop at the next scheme.
re.submatches do not overlap. With a plain\S+tail,["http://example.com","http://u:[email protected]"],http://example.com,http://u:[email protected]andhttps://example.com/login?next=https://u:[email protected]/xare each one candidate whose userinfo is empty, so the second URL's password would pass through. Today's regex masks the second URL in all three. - Why not stop at quotes or angle brackets. A raw
"in a password (http://u:pa"[email protected]/) would then cut the candidate before its '@' and leak. Today's regex masks it. - Speed. The uncapped scheme
[A-Za-z][A-Za-z0-9+.-]*://takes quadratic time: offline, 40,000 letters with no://took 2.0 s and 3.8 s in two runs. The capped pattern with the lookahead stays linear (see the speed criterion). - A scheme longer than 32 characters still matches from a later letter, so its authority is still found.
- Why stop at the next scheme.
- Masking. Parse each candidate with
urllib.parse.urlsplit, which also splits userinfo at the last '@'.- If urllib finds a password (
password is not None, which covers an empty username as inredis://:pw@…), replace only the userinfo inside the candidate text with the<masked-user>:<masked-password>markers (key question 4). The userinfo is thelen(username) + 1 + len(password)characters afterscheme://;urlsplitreturns both undecoded. - A lone username (
ssh://[email protected]/o/r) follows key question 1:<masked-user>@if yes, unchanged if no. - Never re-serialise the URL. httpx2 turns
HTTP://U:[email protected]:80/a/../bintohttp://U:***@example.com/b, so review diffs would show lowercased schemes and hosts, punycoded names, dropped default ports and removed dot segments. It also rejects the templatepostgresql://{user}:{password}@{host}:{port}/{db}(Invalid port: '{port}').
- If urllib finds a password (
- Fail closed only for candidates that contain '@'. Such a candidate becomes
<masked-url>whenurlsplitraises, or when urllib found no userinfo and reading.portraisesValueError. The second case is how urllib reportsroot:pa/ss@…andu:pa#ss@…, where it takes the start of the password for a port.- A candidate without '@' stays as is.
- Templates such as
f"postgresql://{user}:{password}@{host}:{port}/{db}"have userinfo, so only their userinfo is replaced. - A candidate urllib rejects is replaced whole, trailing characters included. In
["http://example.com","http://u:[email protected]"]the second candidate ishttp://u:[email protected]"]. Its authority ends in"], which urllib rejects as a broken IPv6 host, so the output ends"<masked-url>. Nothing leaks, but the"]is lost. With a path (…@example.com/x"]), the"]falls in the path and only the userinfo changes.
- Known limit (free text only). A password that parses as a port (
mysql://root:12/[email protected]/x,http://u:1234#[email protected]/,http://u:/[email protected]/) looks the same as a credential-free URL with a port and a later '@' (http://example.com:8080/[email protected],https://example.com:8443/@user). Those must stay unchanged in review diffs, so these candidates stay as written, as they do under today's regex. A password that contains://also stays, because it starts a new candidate. Single URLs fail closed on both (above).
- Finding candidates. A candidate starts at a scheme in RFC 3986's grammar (section 3.1), capped at 32 characters:
- The two callers that pass free text (gitops.py:399, sandbox/metrics.py:446) drop the inner
mask_uri_credentialscall. They keep the free-text redactor they already apply. - Telemetry endpoint.
- Parse strictly with
urlsplit. httpx2 acceptshttp://[invalid-ipv6as host%5Binvalid-ipv6, whileurlsplitraises and the function returns<internal-endpoint>, as tested. - Classify the host with fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897's loopback predicate and
ipaddress'sis_global. - Build the result with
httpx2.URL(scheme=…, host=…, port=…, path=…), which brackets IPv6 hosts and carries no userinfo. The masked host is the URL-safeinternal-ip.
- Parse strictly with
- served_by. One helper reads the header named by
CONST_AI_GATEWAY_SERVED_BY_HEADERfrom a reply's headers and returns its value without userinfo, usinghttpx2.URL(value).copy_with(userinfo=b""). It sits in ai/client/network.py besidestream_served_by(:53).- Both readers today (openai.py:175, :205) call it. So must any later reader, such as the failed-attempt rows that fix(ai): the spend ledger records every attempt the gateway failed, including the retry transport's, and its gap to the gateway's count is measured first #1019 adds.
- A bare
host:portvalue comes out unchanged. - The single-URL fail-closed rule applies, with absent in place of the placeholder. A value httpx2 rejects is stored as absent. So is a value with '@' where httpx2 finds no userinfo:
copy_withreturnshttp://u:12/[email protected]:11434unchanged. - A test fails if any module under src/devops_cli, other than config/constants.py and the helper's module, names the constant or the header literal
x-litellm-model-api-base.
- The wrapper is deleted. The route (server/routes/telemetry.py:48) calls
sanitize_telemetry_endpointdirectly. - Out of scope:
- the docs crawler's slug built from
user:token@host(ai/library/docs_ingester.py:233-237), which belongs to fix(security): URL and host:port reads use the sending client's parser, so key trust, crawls, probes and settings act on the host actually dialled #1112; - the
type (host)backend string (openai.py:138), which belongs to fix(ai): replies carry their server as an httpx2 origin, so a password in an AI URL stays out of output, the spend ledger, metrics, spans and cache #1110.
- the docs crawler's slug built from
Acceptance criteria
- A parametrised, offline table test pins the old and new behaviour:
| Input | Function | Today | After |
|---|---|---|---|
http://u:p@[email protected]/x |
SSRFBlockedError(...).details["target_url"] |
http://<auth>@[email protected]/x |
http://u:***@example.com/x |
http://u: + 300 × p + @example.com/ |
same | masked | http://u:***@example.com/ (masked before the 256-character cut) |
http://192.0.2.1:8000/api |
str(SSRFBlockedError(...)) and target_url |
message holds http://<masked>:8000/api; target_url as given |
the same |
http://169.254.169.254:abc/ |
SSRFBlockedError(...) |
raises ValueError |
constructs; target_url is <masked-url>; the message is SSRF blocked: <masked-url> (…) and holds no 169.254 |
http://u:pw@[2001:db8::1]:8080/p |
mask_uri_credentials |
http://u:***@2001:db8::1:8080/p |
http://u:***@[2001:db8::1]:8080/p |
mysql://root:pa/[email protected]/x, http://u:pa#[email protected]/ |
mask_uri_credentials |
mysql://root:***@example.com/x, http://u:***@example.com/ |
<masked-url> |
mysql://root:12/[email protected]/x, http://u:1234#[email protected]/ |
mask_uri_credentials |
mysql://root:***@example.com/x, http://u:***@example.com/ |
<masked-url> |
http://:[email protected]:8080/data |
mask_uri_credentials |
http://***@example.com:8080/data |
http://***@example.com:8080/data, as today |
https://u:p@[email protected]/x in text |
redact_text |
https://<masked-user>:<masked-password>@[email protected]/x |
https://<masked-user>:<masked-password>@example.com/x |
http://u:[email protected]/x in text |
redact_text |
scheme rewritten to https:// |
http://<masked-user>:<masked-password>@example.com/x |
postgres://app:[email protected]/x, redis://:[email protected]:6379, HTTP://U:[email protected]/, http://:[email protected]/ in text |
redact_text |
unchanged | userinfo replaced by the markers; scheme, host and path as written |
["http://example.com","http://u:[email protected]/x"] |
redact_text |
second URL masked, scheme rewritten to https:// |
["http://example.com","http://<masked-user>:<masked-password>@example.com/x"] |
["http://example.com","http://u:[email protected]"] |
redact_text |
second URL masked, scheme rewritten to https:// |
["http://example.com","<masked-url> (fails closed; no pw) |
https://example.com/login?next=https://u:[email protected]/x |
redact_text |
second URL masked | https://example.com/login?next=https://<masked-user>:<masked-password>@example.com/x |
url=http://example.com;db=postgres://u:[email protected]/x |
redact_text |
unchanged | url=http://example.com;db=postgres://<masked-user>:<masked-password>@example.com/x |
mysql://root:pa/[email protected]/x, http://u:pa#[email protected]/ in text |
redact_text |
unchanged | <masked-url> |
mysql://root:12/[email protected]/x, http://u:1234#[email protected]/ in text |
redact_text |
unchanged | unchanged (the known limit) |
f"postgresql://{user}:{password}@{host}:{port}/{db}" in text |
redact_text |
unchanged | postgresql://<masked-user>:<masked-password>@{host}:{port}/{db}, no placeholder |
<a href="http://u:[email protected]/x">x</a> |
redact_text |
scheme rewritten to https:// |
only the userinfo changes; every other byte is identical |
http://example.com:8080/[email protected], x = "http://[" + h |
redact_text |
unchanged | unchanged |
custom://[email protected]/path, https://[email protected]/o/r |
both maskers | unchanged | as key question 1 decides |
http://[::1]:4318 |
sanitize_telemetry_endpoint |
http://::1:4318 |
http://[::1]:4318 |
http://100.64.1.2:4318 |
same | unchanged | http://internal-ip:4318 |
http://u:[email protected]:4318/v1/traces |
same | http://<internal-ip>:4318/v1/traces |
http://internal-ip:4318/v1/traces |
http://[invalid-ipv6 |
same | <internal-endpoint> |
<internal-endpoint> |
- served_by. A mocked gateway reply has
x-litellm-model-api-base: http://u:[email protected]:11434. On both the blocking and the streaming path, these holdhttp://example.com:11434and nopw:- the ledger row;
- the call-observer payload;
- the event payload;
- the
llm.served_byspan attribute.
- A reply whose header is
http://u:12/[email protected]:11434stores no served_by on either path. - The source test for served_by's helper passes. Today
rg -n 'CONST_AI_GATEWAY_SERVED_BY_HEADER|x-litellm-model-api-base' srcprints config/constants.py:2222 and openai.py:21, :175 and :205. Afterwards it prints only the constant and the helper's module. - Vault. With
VAULT_ADDR=https://u:[email protected]:8200, theget_statusspan'svault_addrattribute and the debug log lines contain nopw. - Speed. A test masks each of these in under 1 s:
- 100 KB of text holding 1,000 credential URLs;
- 100 KB of letters with no
://; - 100 KB with no whitespace holding 25,000
a://; - 100 KB with no whitespace of
http://u:[email protected],repeated. - An offline prototype of these rules took 0.02 to 0.06 s for each across three runs, and no
pwsurvived. The loose bound keeps the test from flaking on slow hosts.
- No construct left.
rg -n -F -e '_replace(netloc' -e 'partition("@")' -e 'https?://[^' -e '://([^:]*)' src/devops_cli/exceptions/security.py src/devops_cli/security/sanitizer.pyprints nothing. Today it prints sanitizer.py:237, :304 and :364, and exceptions/security.py:52-53.rg -n 'mask_uri_credentials\(str\(' srcprints nothing. Today it prints gitops.py:399 and sandbox/metrics.py:446.rg -n '_sanitize_telemetry_endpoint' src testsprints nothing.- Once feat(ci): hand-rolled URL and address parsing fails
devops ci, AGENTS.md makes the library the rule, and reviews stop discarding the findings #1107 has landed: nonet-*ast-grep marker is left in exceptions/security.py or security/sanitizer.py, and the marker ceiling drops by the number removed.
- Tests updated:
- tests/test_consolidation_security_sanitizer.py:
<internal-ip>becomesinternal-ipat :273 and :277. :112-114 follows key question 1, and so do :57, :92 and :104 if its stricter alternative is chosen. - tests/test_exceptions.py:58:
<auth>@becomesuser:***@. - tests/test_subsystem_containment_and_redaction.py:209-215: imports from
devops_cli.security.sanitizer(:210), and<internal-ip>becomesinternal-ipat :214-215. - tests/test_network_security_and_trace_correlation.py: imports from
devops_cli.security.sanitizer(:15, used at :63-81), and<internal-ip>becomesinternal-ipat :69. - These stay green unchanged:
- tests/test_consolidation_security_sanitizer.py:117-147 (
DevOpsCLIErrorandVaultErrormasking); - tests/test_exceptions.py:44-50, which pins
<masked>in the message and an unchangedtarget_url; - tests/test_scan_outcomes_and_gating.py:360-372, which pins
https://<masked-user>:<masked-password>@git.example.com/for an https input; - tests/test_argo_gitops.py:427-442;
- tests/test_docs_ingester.py:201-215;
- tests/test_ai_served_by.py.
- tests/test_consolidation_security_sanitizer.py:117-147 (
- tests/test_consolidation_security_sanitizer.py:
- Tests run offline, with no DNS lookups and no sockets.
uv run devops cipasses. - A changelog.d fragment names:
- the newly covered schemes;
http://URLs keeping their scheme;- the
<masked-url>placeholder; - the
internal-ipplaceholder; - stripping userinfo from served_by.
Key questions
- Should a lone username be masked, as in
https://[email protected]/o/r? Proposed: yes (owner decision). The URL masker writes***@and free text gets<masked-user>@, because in this CLI's URLs a lone username is more often a token than a name.- Costs:
- tests/test_consolidation_security_sanitizer.py:112-114 changes;
- review diffs show
ssh://<masked-user>@github.com/…forssh://[email protected]/….
- The same reasoning applies to the
<token>:x-oauth-basic@form used with GitHub OAuth tokens. There, the URL masker'suser:***@still shows the token. A stricter alternative masks the username whenever a password is present as well (***@). That changes theuser:***@outputs pinned at tests/test_consolidation_security_sanitizer.py:57, :92 and :104.
- Costs:
- May the free-text scan use a regex? Proposed: yes, because no library finds URLs inside prose.
- linkify-it-py 2.2.0 is already locked, via textual's
markdown-it-py[linkify]. Measured offline, it returnedhttps://user:pa@ssforhttps://user:pa@[email protected]/xand found neither themysql://nor thepostgres://URL. - The regex only locates candidates by RFC 3986's scheme grammar;
urlsplitdoes all the parsing. - A comment at the pattern says why no library applies. The pattern sits wherever AGENTS.md places such patterns when this lands; feat(ci): hand-rolled URL and address parsing fails
devops ci, AGENTS.md makes the library the rule, and reviews stop discarding the findings #1107 and docs(agents): a matching table lives beside its one owner, and moves to config/ only when a second package imports it #1016 settle that wording.
- linkify-it-py 2.2.0 is already locked, via textual's
- Why two parsers? Proposed:
httpx2.URLfor single URLs. It is the sending client's parser, and it builds the masked URL with brackets kept.urlsplitfor free text, where the URL must be spliced rather than re-serialised.urlsplitfor the telemetry endpoint too, where httpx2 is looser (http://[invalid-ipv6).- Both split userinfo at the last '@'.
- Which placeholder goes where? Proposed:
***inside URLs that httpx2 builds;internal-ipfor the telemetry host;<masked-url>for a whole value that fails closed, in single URLs and in free text;- in free text, the existing
<masked-user>/<masked-password>markers. ai/tasks/verify_finding_system.md:59 tells the model that checks review findings that<masked-kind>markers are the tool's redactions and that any other mask is the file's own text, so***in a review diff would be misread.<masked-url>follows the marker form.
- Strip served_by's userinfo, or mask it? Proposed: strip it. The ledger groups by served_by (ledger.py:164-165), userinfo adds nothing to a display, and a masked username would still split the groups.
- Does the telemetry endpoint wait for fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897? Proposed: yes. It uses fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897's loopback predicate in place of the tuple at sanitizer.py:352, which fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897 also lists. If this item is ready first, it ships everything else, and the telemetry endpoint follows in a second PR after fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897 PR1.
- Is failing closed on a stray '@' too broad for single URLs? Proposed: no; accept the cost.
- A credential-free URL with '@' only in its path or query becomes
<masked-url>. Today's fallback already garbles such a URL when a ':' follows the scheme:http://example.com:8080/[email protected]becomeshttp://example.com:***@example.com. It leaves one without a ':' unchanged, such ashttps://example.com/x/[email protected]/mod.ts. - The visible cost is in the docs crawler. It labels each chunk and its result with
mask_uri_credentialsof the page URL (ai/library/docs_ingester.py:278, :288), so a page whose path has apackage@versionsegment loses its source label. It never shows a password. - Single-URL inputs are configuration values, SSRF targets and the Vault address, where '@' outside userinfo is rare. Telling such a URL from a password that starts with digits would need a hand-written check of the authority, which the library-first rule forbids.
- A credential-free URL with '@' only in its path or query becomes
Strategic alignment
- Priority P1. Credentials reach terminal output, error details, run results, review prompts, the spend ledger and spans.
- Proposed milestone: backlog (P1), picked by the release-start fill.
- Size: medium. It touches sanitizer.py, exceptions/security.py, two call sites, ai/client/network.py, openai.py, vault_broker.py and the route, plus about seven test files.
- Sequence: after feat(ci): hand-rolled URL and address parsing fails
devops ci, AGENTS.md makes the library the rule, and reviews stop discarding the findings #1107, in parallel with fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897, fix(docker): the Docker endpoint check covers the endpoint the SDK dials, including contexts and the TUI, and pushes accept registry ports #1108, fix(git): GitHub clones trust GitHub's published host keys through OpenSSH, so junk known_hosts lines and a failed key scan no longer skip pinning #1114 and fix(security): URL and host:port reads use the sending client's parser, so key trust, crawls, probes and settings act on the host actually dialled #1112. The telemetry-endpoint part waits for fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897 PR1. - Shared files, on different lines:
- ai/client/openai.py with fix(ai): replies carry their server as an httpx2 origin, so a password in an AI URL stays out of output, the spend ledger, metrics, spans and cache #1110 (:138);
- security/vault_broker.py with fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898 (:113, :158, :179) and fix(security): URL and host:port reads use the sending client's parser, so key trust, crawls, probes and settings act on the host actually dialled #1112 (:37-58);
- sandbox/metrics.py with fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897 (:398) and fix(security): URL and host:port reads use the sending client's parser, so key trust, crawls, probes and settings act on the host actually dialled #1112 (:645-649);
- security/sanitizer.py:352 with fix(security): egress guards refuse cloud metadata in every numeric, NAT64 and provider form, classified by ipaddress and one maintained library #897.
- Use a changelog.d fragment only.
- Related:
- fix(security): secret masking tells code from literals by the file's syntax, not by receiver names #889 edits the same file but different functions (
_is_code_valueat sanitizer.py:124-134 andmask_secrets's signature at :269), so whichever lands second rebases. URL-credential masking stays in force under both of fix(security): secret masking tells code from literals by the file's syntax, not by receiver names #889's syntaxes. - fix(ai): the spend ledger records every attempt the gateway failed, including the retry transport's, and its gap to the gateway's count is measured first #1019 records failed attempts in the spend ledger, with the backend that served each one when the error response names it. That adds a reader of
x-litellm-model-api-basethat writes into the same served_by column. It reads the header through this item's helper. If fix(ai): the spend ledger records every attempt the gateway failed, including the retry transport's, and its gap to the gateway's count is measured first #1019 lands first, this item moves that reader onto the helper, and the source test enforces it either way.
- fix(security): secret masking tells code from literals by the file's syntax, not by receiver names #889 edits the same file but different functions (
- Policy: it follows AGENTS.md:20 and :25 (the standard library and httpx2 instead of custom workarounds) and the no-shims rule at :91.
Metadata
Metadata
Assignees
Labels
priority/p1-highPriority P1: high-impact work for the next planned milestonescope/aiAI review pipeline, personas, prompts, LLM client, or RAGscope/securitySecurity linters (trivy, bandit, gitleaks, kubeconform) and Vaultscope/telemetryOpenTelemetry tracing spans, Prometheus metrics, and Jaegertype/securityType security: a vulnerability or a leak
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 8, 2026
Placed in v0.2.31 on 2026-10-08 at the owner's request ("Populate 10 security and ci issues into each v0.2.30, v0.2.31, and v0.2.32 milestone"). This is a person's placement. Release theme: finding identity v2, URL credential masking, tests that leave no state, the Docker endpoint check and the Argo CD/OTel perimeters. Position 3 of 10 in the release's planned merge order. This item still needs refinement before its release starts (see the planning note), so its board Status stays New.
dan-petty commentedon Oct 8, 2026
Owner decision, 2026-10-08, on key question 1: a URL that carries only a username (for example
https://[email protected]) is not masked. Only passwords are masked, through urllib and httpx2 as this item specifies. This answers the item's open question, so it is Ready and placed in v0.2.31.fix(security): URL credential masking uses urllib and httpx2 (#1109) (#…
dan-petty-bot commentedon Oct 9, 2026
What changed
#1488, merged into
release/v0.2.31as 0b06ff4.17 file(s) changed.
How it was verified
Check runs at 1a6bf36:
Acceptance Criteria of
docs/agent/tasks/task-1109-url-credential-masking.md:tests/test_url_credential_masking.py::test_acceptance_criteria_table).@,#, or/are masked properly, IPv6 host brackets remain intact, and non-HTTP schemes are covered.http://URLs keep their scheme without being rewritten tohttps://.<masked-url>placeholder.100.64.0.0/10), link-local, and documentation IPs in telemetry endpoints are masked to theinternal-ipplaceholder.served_byacross blocking and streaming paths (test_gateway_served_by_blocking_and_streaming_strips_credentials).config/constants.pyandai/client/network.pyreferencex-litellm-model-api-baseorCONST_AI_GATEWAY_SERVED_BY_HEADER.get_statusspan attributevault_addrcontains no credentials (test_vault_broker_status_span_masks_credentials).test_free_text_masking_speed)._replace(netloc,partition("@"),https?://[^,://([^:]*)) are completely eliminated fromexceptions/security.pyandsecurity/sanitizer.py(test_no_forbidden_constructs_remain).mask_uri_credentials(str(eliminated fromsrc/._sanitize_telemetry_endpointwrapper eliminated fromsrc/andtests/.changelog.d/1109.mdrecords the change.uv run devops cipasses.feat(release): v0.2.31 (#1490)