Skip to content

fix(daemon): refuse control bytes in a name-converter request - #7346

Merged
oferchen merged 1 commit into
masterfrom
fix/namecvt-token-injection
Aug 15, 2026
Merged

oferchen merged 1 commit into
masterfrom
fix/namecvt-token-injection

Conversation

@oferchen

Copy link
Copy Markdown
Owner

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 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.

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.
@github-actions github-actions Bot added the bug Something isn't working label Aug 15, 2026
@oferchen
oferchen merged commit 65e0711 into master Aug 15, 2026
70 checks passed
@oferchen
oferchen deleted the fix/namecvt-token-injection branch August 15, 2026 04:10
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant