fix(relay): reject events containing NUL characters at validation time - #3202
Open
rvaccone wants to merge 1 commit into
Open
fix(relay): reject events containing NUL characters at validation time#3202rvaccone wants to merge 1 commit into
rvaccone wants to merge 1 commit into
Conversation
Postgres cannot store NUL in text/jsonb columns, so an event carrying \u0000 in its content or a tag value passed validation and then failed at insert time, surfacing as a 500 internal error instead of a clean invalid: rejection. Fixes block#3116 Signed-off-by: Rocco Vaccone <rocco@vaccone.us>
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.
Events with
\u0000in content or a tag value pass signature verification, thenfail at Postgres insert with
invalid byte sequence for encoding "UTF8": 0x00,surfacing as a 500. Postgres text and jsonb cannot contain the NUL character.
Fixes #3116.
ingest_event_innernow rejects NUL in content or any tag element, next to thecontent size check. Both transports route through it.
id,pubkey, andsigare hex and cannot carry NUL; profiles (kind 0) and workflow definitions
(kind 30620) are ordinary events, so the paths named in the issue are covered.
Verified live: 500 before, 400
invalid: content contains a NUL characterorinvalid: tag value contains a NUL characterafter, no row written, cleanevents unaffected. Four unit tests added; fmt and clippy pass. The 9 failing
buzz-relay --libtests also fail at the merge base (noted as preexistingin #3128).