Drop an unrecognised inReplyTo instead of the message - #40
Merged
Merged
Conversation
The CodeQL autofix made an inbound message fail outright when its
inReplyTo is not one of our TypeIDs. A peer's message ids are the peer's
business: a UUID there is perfectly conformant A2A, it simply cannot
match a token we issued. The bus already treats an in-reply-to matching
no pending ask as ordinary mail, so refusing the request turned a
message we can read into an error the peer cannot act on.
The token is still validated before it travels any further, which is
what the alert was pointing at, so what changes is only what happens
when validation fails.
Worth saying about the alert itself: the sink is
Where("reply_with = ?", replyWith) on sqlite and postgres and a bson
value on mongo, so there was no injection to fix. Validating is cheap
and worth keeping regardless; refusing conformant peers was the part to
undo.
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.
This revisits the Copilot autofix in 01f9e49. That commit made an inbound A2A message fail outright when its
inReplyTois not one of our TypeIDs, and I think the rejection is the wrong half of it.Why refusing is wrong
A peer's message ids are the peer's business. Ours are TypeIDs; a conformant A2A implementation might use UUIDs, or a sequence, or anything else. A message quoting one of those in
inReplyTois still a valid message, and it simply cannot match a token we issued.The bus was already built for that case.
TestUnmatchedReplyIsJustAMessageina2a/bus_reply_test.gopins it: an in-reply-to matching no pending ask is delivered as ordinary mail and resumes nothing. Refusing the request instead turns a message we can read into an error the peer cannot act on, and it means cortex cannot hold a conversation with any peer whose ids are not shaped like ours.So the token is still validated, which is what the alert was pointing at. What changes is what happens when validation fails: the correlation is dropped, the message is delivered.
Why the alert was a false positive
The value reaches
ClaimPendingAsk, and the sinks are:A bound parameter and a bson value. There was no injection to fix. Validating the shape is still cheap and worth keeping as defence in depth, so I kept it. Refusing conformant peers is the part worth undoing.
The alert can be dismissed as a false positive once this lands, or left resolved by the validation that is still there.
Tests
Two, and the first is the regression:
inReplyTocarrying a UUID is accepted, with the correlation droppedinReplyTocarrying one of our own tokens still correlatesThe existing suite passes unchanged,
golangci-lintis clean, and no test covered the non-TypeID case before, which is how the autofix passed CI while changing behaviour.