fix(inbound): single-use nonce on relay provenance proofs (review 2026-10-21 05/O1)

This commit is contained in:
Joseph Doherty
2026-10-22 08:31:54 -04:00
parent 26baa5a170
commit e93af5a21f
3 changed files with 56 additions and 4 deletions
@@ -98,7 +98,6 @@ public sealed class HttpStandbyRequestForwarder : IStandbyRequestForwarder
// already enforced MaxRequestBodyBytes (Content-Length up front, and the
// per-request Kestrel cap for chunked bodies), so this is bounded.
var body = await RelayProvenance.ReadBoundedAsync(context.Request.Body, opts.MaxRequestBodyBytes, cancellationToken);
var provenance = RelayProvenance.Sign(context, body, opts.ApiKeyPepper);
var client = _httpClientFactory.CreateClient(HttpClientName);
var pathAndQuery = context.Request.Path.Value + context.Request.QueryString.Value;
@@ -115,6 +114,8 @@ public sealed class HttpStandbyRequestForwarder : IStandbyRequestForwarder
try
{
// A fresh proof (own nonce) per attempt: each is single-use at the receiver.
var provenance = RelayProvenance.Sign(context, body, opts.ApiKeyPepper);
using var request = BuildRequest(context, peer, pathAndQuery, body, forwardedBy, provenance);
using var response = await client
.SendAsync(request, HttpCompletionOption.ResponseHeadersRead, deadline.Token)