Refuse in a text field what the bus will refuse #7

Open
opened 2026-11-22 13:22:26 +00:00 by jorijnvdgraaf · 0 comments

A text field of the app takes text that D-Bus will not carry. The form shows it, and sending the form fails with "text that is not UTF-8 cannot be sent to nostrod. Nothing was sent.", for text that may well be UTF-8. The user is not told which character is at fault, and it may be one the font draws nothing for.

Found by the pre-push review of 1.0.0 (the approach and bug-prover lenses). It is older than that release. Since 1.0.0 the reader of pay links keeps such text out of a form a link fills in (Plain() in Nostro.App-Forms.cpp), by checks of its own beside the decoder; a field that is typed or pasted into has no such check.

Where

Links are to the tree at 8dd31e2 (1.0.0).

  • Ui::DecodeUtf8 gives U+FFFD for a byte that begins nothing and for a sequence cut short. It takes a sequence longer than its character needs (C0 AF reads as /), half of a surrogate pair (ED A0 80), a code point past U+10FFFF (F4 90 80 80) and the noncharacters (U+FDD0 to U+FDEF, and the last two code points of every plane).
  • Taken, which decides what a field keeps of what is typed or pasted, keeps in a field of text every code point from U+0020 up but U+007F and a U+FFFD that is not its own three bytes. A field of digits keeps what decodes to a digit, in the bytes it came in, an over-long 5 among them. Its comment gives the aim: "the bus carries valid UTF-8 alone".
  • sd-bus refuses all of the above when the form's text is appended to the call (Wire<std::string>::Append), and Explain words that as input the user got wrong.

Concrete case

Paste a description that holds U+1FFFE (F0 9F BF BE) into the pay form. The field keeps it; what the font draws for it was not looked at. Press Pay: "That cannot be done. text that is not UTF-8 cannot be sent to nostrod. Nothing was sent." The same goes for an over-long sequence, which the field draws as the character it spells.

No money moves, and nothing reaches a dialog or the bank: the call is never sent.

What it would take

  • Have DecodeUtf8 give U+FFFD for an over-long sequence, a surrogate and a code point past U+10FFFF. Taken then drops them as it drops any malformed sequence, and Plain() in Nostro.App-Forms.cpp can lose its own check for the shortest form.
  • Have Taken drop the noncharacters as well, which are valid UTF-8 and which sd-bus refuses all the same. The library's Unshown lacks those of the planes after the first as well: #6.
  • ShouldEditText gets the cases: each of these pasted into a field of each kind.

What was run, and what was read

Run, against libsystemd 262.1: sd_bus_message_append_basic with type s returns -EINVAL for U+FFFE, U+FDD0, U+1FFFE, U+2FFFF, U+EFFFF and U+10FFFF, for an over-long sequence and for a character cut short, and takes private use (U+E000, U+F0000). That the decoder and Taken let these through is from reading the code, and from ShouldValidateForms, whose cases for a link's over-long and noncharacter text pass only through Plain()'s own checks. Pasting into the running app was not tried.

A text field of the app takes text that D-Bus will not carry. The form shows it, and sending the form fails with "text that is not UTF-8 cannot be sent to nostrod. Nothing was sent.", for text that may well be UTF-8. The user is not told which character is at fault, and it may be one the font draws nothing for. Found by the pre-push review of 1.0.0 (the approach and bug-prover lenses). It is older than that release. Since 1.0.0 the reader of pay links keeps such text out of a form a link fills in (`Plain()` in `Nostro.App-Forms.cpp`), by checks of its own beside the decoder; a field that is typed or pasted into has no such check. ## Where Links are to the tree at 8dd31e2 (1.0.0). - [`Ui::DecodeUtf8`](https://forgejo.catcrafts.net/Catcrafts/Nostro/src/commit/8dd31e2bb9eb3ac3f7c73ea5f35ad1986b61877b/implementations/Nostro.Ui-Text.cpp#L11-L43) gives U+FFFD for a byte that begins nothing and for a sequence cut short. It takes a sequence longer than its character needs (`C0 AF` reads as `/`), half of a surrogate pair (`ED A0 80`), a code point past U+10FFFF (`F4 90 80 80`) and the noncharacters (U+FDD0 to U+FDEF, and the last two code points of every plane). - [`Taken`](https://forgejo.catcrafts.net/Catcrafts/Nostro/src/commit/8dd31e2bb9eb3ac3f7c73ea5f35ad1986b61877b/implementations/Nostro.Ui-Edit.cpp#L25-L54), which decides what a field keeps of what is typed or pasted, keeps in a field of text every code point from U+0020 up but U+007F and a U+FFFD that is not its own three bytes. A field of digits keeps what decodes to a digit, in the bytes it came in, an over-long `5` among them. Its comment gives the aim: "the bus carries valid UTF-8 alone". - sd-bus refuses all of the above when the form's text is appended to the call ([`Wire<std::string>::Append`](https://forgejo.catcrafts.net/Catcrafts/Nostro/src/commit/8dd31e2bb9eb3ac3f7c73ea5f35ad1986b61877b/implementations/Nostro-Bus.cpp#L123-L130)), and `Explain` words that as input the user got wrong. ## Concrete case Paste a description that holds U+1FFFE (`F0 9F BF BE`) into the pay form. The field keeps it; what the font draws for it was not looked at. Press Pay: "That cannot be done. text that is not UTF-8 cannot be sent to nostrod. Nothing was sent." The same goes for an over-long sequence, which the field draws as the character it spells. No money moves, and nothing reaches a dialog or the bank: the call is never sent. ## What it would take - Have `DecodeUtf8` give U+FFFD for an over-long sequence, a surrogate and a code point past U+10FFFF. `Taken` then drops them as it drops any malformed sequence, and `Plain()` in `Nostro.App-Forms.cpp` can lose its own check for the shortest form. - Have `Taken` drop the noncharacters as well, which are valid UTF-8 and which sd-bus refuses all the same. The library's `Unshown` lacks those of the planes after the first as well: #6. - `ShouldEditText` gets the cases: each of these pasted into a field of each kind. ## What was run, and what was read Run, against libsystemd 262.1: `sd_bus_message_append_basic` with type `s` returns `-EINVAL` for U+FFFE, U+FDD0, U+1FFFE, U+2FFFF, U+EFFFF and U+10FFFF, for an over-long sequence and for a character cut short, and takes private use (U+E000, U+F0000). That the decoder and `Taken` let these through is from reading the code, and from `ShouldValidateForms`, whose cases for a link's over-long and noncharacter text pass only through `Plain()`'s own checks. Pasting into the running app was not tried.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Catcrafts/Nostro#7
No description provided.