Repository navigation
fix(daemon): refuse control bytes in a name-converter request - #7346
Merged
Merged
Conversation
A peer-supplied name containing a newline desynchronises the name-converter
stream for the rest of the session. The converter protocol is one request line
in, one answer line out; `query()` formatted `"{cmd} {arg}\n"` with no
validation, so a name of `zz\nusr root` is TWO request lines. The converter
answers twice, `query()` reads once, and the surplus answer stays buffered for
the NEXT lookup to consume.
Measured, on a converter that answers per name: after that request, `alice`
resolves to **uid 0** instead of 1001, and every later lookup in the session
stays shifted by one. The name bytes come straight off the wire - the id-list
decoder reads a length byte then that many RAW bytes - so the input is
peer-controlled.
upstream added `namecvt_safe_token()` in 3.5.0 (clientserver.c:1362), called at
:1317 BEFORE the request is formatted, refusing any byte below `' '` or equal
to 0x7f. 3.4.4 has no such function. Only `\n` is exploitable; the rest of the
class comes along because upstream refuses the class, not the one byte.
The FILED CVE SHAPE IS REFUTED - oc never had that bug. 3.5.0's same hunk also
replaced `*id_p = (id_t)atol(buf)` (3.4.4 clientserver.c:1252) with a strict
digit walk, because `atol("")` is 0 and an unknown name would map to root. oc
returns None on an empty line and parses with `str::parse::<u32>`, which
rejects empty, non-digit and overflowing input, so the reply arm was already
correct. The gap is the REQUEST arm, in the same upstream change.
Two smaller parts of the same hunk, both upstream-cited:
- The size guard was `> 1024` where upstream refuses at `len >= sizeof buf`
(:1322). At exactly 1024 upstream has already truncated, so oc sent a
silently-truncated name.
- `parse_converter_id()` now walks the digits explicitly (:1345-1348) instead
of `str::parse`, which accepts a leading `+`.
Deliberately NOT included, though found alongside: upstream refuses an empty
name BEFORE consulting the converter (uidlist.c:146, :172) and oc does not, and
oc's `query()` collapses write-failure, EOF, not-found and unparseable into one
`None` where upstream aborts the session on the first two (:1329-1334). Both
are real, both live in a different upstream function, and neither is needed to
close this one. They are filed separately rather than folded in.
Verification: 18/18 green. Three mutations, each lethal, each count reconciling
against the run total so no fail-fast truncation is hiding kills - remove the
token guard: 16 passed + 2 failed = 18; restore `>` for `>=`: 17 + 1 = 18;
unwire the digit rule: 17 + 1 = 18. fmt clean; clippy -D warnings clean.
The tests assert the REQUEST COUNT the converter actually received, not just
the returned None. That distinction is load-bearing and was found by mutation:
an earlier version of these tests asserted only `None`, and four of the five
passed with the guard removed - a refused name and a name that was sent and
answered "unknown" both return None, so the guard was invisible. Counting
received requests is what makes "refused before the write" observable.
oferchen
added a commit
that referenced
this pull request
Aug 24, 2026
A peer-supplied name containing a newline desynchronises the name-converter
stream for the rest of the session. The converter protocol is one request line
in, one answer line out; `query()` formatted `"{cmd} {arg}\n"` with no
validation, so a name of `zz\nusr root` is TWO request lines. The converter
answers twice, `query()` reads once, and the surplus answer stays buffered for
the NEXT lookup to consume.
Measured, on a converter that answers per name: after that request, `alice`
resolves to **uid 0** instead of 1001, and every later lookup in the session
stays shifted by one. The name bytes come straight off the wire - the id-list
decoder reads a length byte then that many RAW bytes - so the input is
peer-controlled.
upstream added `namecvt_safe_token()` in 3.5.0 (clientserver.c:1362), called at
:1317 BEFORE the request is formatted, refusing any byte below `' '` or equal
to 0x7f. 3.4.4 has no such function. Only `\n` is exploitable; the rest of the
class comes along because upstream refuses the class, not the one byte.
The FILED CVE SHAPE IS REFUTED - oc never had that bug. 3.5.0's same hunk also
replaced `*id_p = (id_t)atol(buf)` (3.4.4 clientserver.c:1252) with a strict
digit walk, because `atol("")` is 0 and an unknown name would map to root. oc
returns None on an empty line and parses with `str::parse::<u32>`, which
rejects empty, non-digit and overflowing input, so the reply arm was already
correct. The gap is the REQUEST arm, in the same upstream change.
Two smaller parts of the same hunk, both upstream-cited:
- The size guard was `> 1024` where upstream refuses at `len >= sizeof buf`
(:1322). At exactly 1024 upstream has already truncated, so oc sent a
silently-truncated name.
- `parse_converter_id()` now walks the digits explicitly (:1345-1348) instead
of `str::parse`, which accepts a leading `+`.
Deliberately NOT included, though found alongside: upstream refuses an empty
name BEFORE consulting the converter (uidlist.c:146, :172) and oc does not, and
oc's `query()` collapses write-failure, EOF, not-found and unparseable into one
`None` where upstream aborts the session on the first two (:1329-1334). Both
are real, both live in a different upstream function, and neither is needed to
close this one. They are filed separately rather than folded in.
Verification: 18/18 green. Three mutations, each lethal, each count reconciling
against the run total so no fail-fast truncation is hiding kills - remove the
token guard: 16 passed + 2 failed = 18; restore `>` for `>=`: 17 + 1 = 18;
unwire the digit rule: 17 + 1 = 18. fmt clean; clippy -D warnings clean.
The tests assert the REQUEST COUNT the converter actually received, not just
the returned None. That distinction is load-bearing and was found by mutation:
an earlier version of these tests asserted only `None`, and four of the five
passed with the guard removed - a refused name and a name that was sent and
answered "unknown" both return None, so the guard was invisible. Counting
received requests is what makes "refused before the write" observable.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix(daemon): refuse control bytes in a name-converter request
A peer-supplied name containing a newline desynchronises the name-converter
stream for the rest of the session. The converter protocol is one request line
in, one answer line out;
query()formatted"{cmd} {arg}\n"with novalidation, so a name of
zz\nusr rootis TWO request lines. The converteranswers twice,
query()reads once, and the surplus answer stays buffered forthe NEXT lookup to consume.
Measured, on a converter that answers per name: after that request,
aliceresolves to uid 0 instead of 1001, and every later lookup in the session
stays shifted by one. The name bytes come straight off the wire - the id-list
decoder reads a length byte then that many RAW bytes - so the input is
peer-controlled.
upstream added
namecvt_safe_token()in 3.5.0 (clientserver.c:1362), called at:1317 BEFORE the request is formatted, refusing any byte below
' 'or equalto 0x7f. 3.4.4 has no such function. Only
\nis exploitable; the rest of theclass comes along because upstream refuses the class, not the one byte.
The FILED CVE SHAPE IS REFUTED - oc never had that bug. 3.5.0's same hunk also
replaced
*id_p = (id_t)atol(buf)(3.4.4 clientserver.c:1252) with a strictdigit walk, because
atol("")is 0 and an unknown name would map to root. ocreturns None on an empty line and parses with
str::parse::<u32>, whichrejects empty, non-digit and overflowing input, so the reply arm was already
correct. The gap is the REQUEST arm, in the same upstream change.
Two smaller parts of the same hunk, both upstream-cited:
> 1024where upstream refuses atlen >= sizeof buf(:1322). At exactly 1024 upstream has already truncated, so oc sent a
silently-truncated name.
parse_converter_id()now walks the digits explicitly (:1345-1348) insteadof
str::parse, which accepts a leading+.Deliberately NOT included, though found alongside: upstream refuses an empty
name BEFORE consulting the converter (uidlist.c:146, :172) and oc does not, and
oc's
query()collapses write-failure, EOF, not-found and unparseable into oneNonewhere upstream aborts the session on the first two (:1329-1334). Bothare real, both live in a different upstream function, and neither is needed to
close this one. They are filed separately rather than folded in.
Verification: 18/18 green. Three mutations, each lethal, each count reconciling
against the run total so no fail-fast truncation is hiding kills - remove the
token guard: 16 passed + 2 failed = 18; restore
>for>=: 17 + 1 = 18;unwire the digit rule: 17 + 1 = 18. fmt clean; clippy -D warnings clean.
The tests assert the REQUEST COUNT the converter actually received, not just
the returned None. That distinction is load-bearing and was found by mutation:
an earlier version of these tests asserted only
None, and four of the fivepassed with the guard removed - a refused name and a name that was sent and
answered "unknown" both return None, so the guard was invisible. Counting
received requests is what makes "refused before the write" observable.