Skip to content

HTTP API Gateway request deserialization fails on control characters in header #1188

Open

Description

@tenjaa

Hi,

I run a something on the internet and from time to time I see my rust lambda throwing an error.
Looking into it, it seems that control characters in the header fail during deserialization.

After activating trace logs and looking at the payload of the lambda, the user agent header looks like this:

"user-agent": "\u0013\u0014\u0015\u0016\u0017\u0018"

Is there a supported way to handle or reject such requests in the application without throwing an error?
If you tell me what the expected handling is, I would be willing to provide a PR.


Architecture: CloudFront => HTTP API Gateway => Rust Lambda

Error:

Request payload deserialization into LambdaEvent<T> failed. The handler will not be called. Log at TRACE level to see the payload. error=DeserializeError { inner: Error { path: Path { segments: [Map { key: "headers" }] }, original: Error("invalid value: string \"\\u{13}\\u{14}\\u{15}\\u{16}\\u{17}\\u{18}\", expected lots of things can go wrong with HeaderMap", line: 1, column: 279) } }

Reproduction:

curl --http1.1 -i \
  -H $'User-Agent: \x13\x14\x15\x16\x17\x18' \
  'https://my.domain/abc'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions