Skip to content

x-pack/filebeat/input/http_endpoint: limit request body buffered for HMAC validation - #53937

Merged
efd6 merged 1 commit into
elastic:mainfrom
efd6:s11807-http_endpoint
Nov 3, 2026
Merged

efd6 merged 1 commit into
elastic:mainfrom
efd6:s11807-http_endpoint

Conversation

@efd6

@efd6 efd6 commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Proposed commit message

x-pack/filebeat/input/http_endpoint: limit request body buffered for HMAC validation

When HMAC validation is configured, the whole request body is buffered
so that the signature can be checked and the body replayed to the
handler. That read had no limit unless max_body_bytes was set, and the
bytes were not counted against max_in_flight_bytes, since the handler
only wraps the body in its counting reader after validation.

Limit the read to 25 MiB when max_body_bytes is not set. This is at
least as large as the largest payload GitHub sends to webhooks, which
it caps at 25 MB. Larger bodies are rejected with a 413 before the
signature is checked. An explicit max_body_bytes keeps its existing
behaviour. When max_in_flight_bytes is set, count the buffered bytes
against it during validation and respond with a 503 and a Retry-After
header, as the handler does when the limit is exceeded while reading.
The in_flight value in that response is zero, since the bytes are
released when validation returns.

The request tracer reads the whole body of a rejected request to log
it. Limit that read to what is logged, so that rejecting an oversized
body does not buffer the rest of it.

HMAC requests with bodies larger than 25 MiB and no max_body_bytes were
previously accepted and are now rejected. The limit is per request;
max_in_flight_bytes is what limits the total.

Note

The applies_to tags are only for 9.5+, but we'll have this coming in at a patch level. Please make sure I've done this correctly.

Note

This has a potential impact on integrations that cannot set max_body_bytes.

Checklist

  • My code follows the style guidelines of this project
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have made corresponding change to the default configuration files
  • I have added tests that prove my fix is effective or that my feature works. Where relevant, I have used the stresstest.sh script to run them under stress conditions and race detector to verify their stability.
  • I have added an entry in ./changelog/fragments using the changelog tool.

Disruptive User Impact

HTTP Endpoint inputs with HMAC validation and no max_body_bytes now reject request bodies over 25 MiB with a 413. Before, they accepted any size. Users who receive larger signed payloads should set max_body_bytes. When max_in_flight_bytes is set, the bytes read for HMAC validation count towards it, so a request that goes over it gets a 503 before its signature is checked, where before a bad signature got a 401. The Fleet integrations that use HMAC (http_endpoint, kolide and the deprecated ti_anomali.threatstream) don't expose max_body_bytes, so their users can't raise the limit.

How to test this PR locally

Related issues

Use cases

Screenshots

Logs

@efd6 efd6 self-assigned this Oct 20, 2026
@efd6 efd6 added Filebeat Filebeat bugfix Team:Security-Service Integrations Security Service Integrations Team backport-8.19 Automated backport to the 8.19 branch backport-9.5 Automated backport to the 9.5 branch backport-9.6 Automated backport to the 9.6 branch labels Oct 20, 2026
@botelastic botelastic Bot added needs_team Indicates that the issue/PR needs a Team:* label and removed needs_team Indicates that the issue/PR needs a Team:* label labels Oct 20, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)
  • /test : Run the Buildkite pipeline.

@github-actions

github-actions Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🔍 Preview links for changed docs

@github-actions

Copy link
Copy Markdown
Contributor

Elastic Docs Style Checker (Vale)

Summary: 1 warning found

⚠️ Warnings (1): Fix when the suggestion improves clarity or correctness.
File Line Rule Message
docs/reference/filebeat/filebeat-input-http_endpoint.md 304 Elastic.BritishSpellings Use American English spelling 'toward' instead of British English 'towards'.

The Vale linter checks documentation changes against the Elastic Docs style guide. To use Vale locally or report issues, refer to Elastic style guide for Vale.

…HMAC validation

When HMAC validation is configured, the whole request body is buffered
so that the signature can be checked and the body replayed to the
handler. That read had no limit unless max_body_bytes was set, and the
bytes were not counted against max_in_flight_bytes, since the handler
only wraps the body in its counting reader after validation.

Limit the read to 25 MiB when max_body_bytes is not set. This is at
least as large as the largest payload GitHub sends to webhooks, which
it caps at 25 MB. Larger bodies are rejected with a 413 before the
signature is checked. An explicit max_body_bytes keeps its existing
behaviour. When max_in_flight_bytes is set, count the buffered bytes
against it during validation and respond with a 503 and a Retry-After
header, as the handler does when the limit is exceeded while reading.
The in_flight value in that response is zero, since the bytes are
released when validation returns.

The request tracer reads the whole body of a rejected request to log
it. Limit that read to what is logged, so that rejecting an oversized
body does not buffer the rest of it.

HMAC requests with bodies larger than 25 MiB and no max_body_bytes were
previously accepted and are now rejected. The limit is per request;
max_in_flight_bytes is what limits the total.
@efd6
efd6 force-pushed the s11807-http_endpoint branch from 8f8716f to 5da33ee Compare October 21, 2026 00:44
@efd6
efd6 marked this pull request as ready for review October 21, 2026 02:12
@efd6
efd6 requested review from a team as code owners October 21, 2026 02:12
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@vishaangelova vishaangelova left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM for the docs

@mergify

mergify Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again.

@efd6
efd6 merged commit e178012 into elastic:main Nov 3, 2026
41 checks passed
efd6 added a commit that referenced this pull request Nov 12, 2026
…HMAC validation (#53937)

When HMAC validation is configured, the whole request body is buffered
so that the signature can be checked and the body replayed to the
handler. That read had no limit unless max_body_bytes was set, and the
bytes were not counted against max_in_flight_bytes, since the handler
only wraps the body in its counting reader after validation.

Limit the read to 25 MiB when max_body_bytes is not set. This is at
least as large as the largest payload GitHub sends to webhooks, which
it caps at 25 MB. Larger bodies are rejected with a 413 before the
signature is checked. An explicit max_body_bytes keeps its existing
behaviour. When max_in_flight_bytes is set, count the buffered bytes
against it during validation and respond with a 503 and a Retry-After
header, as the handler does when the limit is exceeded while reading.
The in_flight value in that response is zero, since the bytes are
released when validation returns.

The request tracer reads the whole body of a rejected request to log
it. Limit that read to what is logged, so that rejecting an oversized
body does not buffer the rest of it.

HMAC requests with bodies larger than 25 MiB and no max_body_bytes were
previously accepted and are now rejected. The limit is per request;
max_in_flight_bytes is what limits the total.

(cherry picked from commit e178012)
efd6 added a commit that referenced this pull request Nov 12, 2026
…HMAC validation (#53937)

When HMAC validation is configured, the whole request body is buffered
so that the signature can be checked and the body replayed to the
handler. That read had no limit unless max_body_bytes was set, and the
bytes were not counted against max_in_flight_bytes, since the handler
only wraps the body in its counting reader after validation.

Limit the read to 25 MiB when max_body_bytes is not set. This is at
least as large as the largest payload GitHub sends to webhooks, which
it caps at 25 MB. Larger bodies are rejected with a 413 before the
signature is checked. An explicit max_body_bytes keeps its existing
behaviour. When max_in_flight_bytes is set, count the buffered bytes
against it during validation and respond with a 503 and a Retry-After
header, as the handler does when the limit is exceeded while reading.
The in_flight value in that response is zero, since the bytes are
released when validation returns.

The request tracer reads the whole body of a rejected request to log
it. Limit that read to what is logged, so that rejecting an oversized
body does not buffer the rest of it.

HMAC requests with bodies larger than 25 MiB and no max_body_bytes were
previously accepted and are now rejected. The limit is per request;
max_in_flight_bytes is what limits the total.

(cherry picked from commit e178012)
efd6 added a commit that referenced this pull request Nov 12, 2026
…HMAC validation (#53937)

When HMAC validation is configured, the whole request body is buffered
so that the signature can be checked and the body replayed to the
handler. That read had no limit unless max_body_bytes was set, and the
bytes were not counted against max_in_flight_bytes, since the handler
only wraps the body in its counting reader after validation.

Limit the read to 25 MiB when max_body_bytes is not set. This is at
least as large as the largest payload GitHub sends to webhooks, which
it caps at 25 MB. Larger bodies are rejected with a 413 before the
signature is checked. An explicit max_body_bytes keeps its existing
behaviour. When max_in_flight_bytes is set, count the buffered bytes
against it during validation and respond with a 503 and a Retry-After
header, as the handler does when the limit is exceeded while reading.
The in_flight value in that response is zero, since the bytes are
released when validation returns.

The request tracer reads the whole body of a rejected request to log
it. Limit that read to what is logged, so that rejecting an oversized
body does not buffer the rest of it.

HMAC requests with bodies larger than 25 MiB and no max_body_bytes were
previously accepted and are now rejected. The limit is per request;
max_in_flight_bytes is what limits the total.

(cherry picked from commit e178012)
efd6 added a commit that referenced this pull request Nov 12, 2026
…HMAC validation (#53937) (#54391)

When HMAC validation is configured, the whole request body is buffered
so that the signature can be checked and the body replayed to the
handler. That read had no limit unless max_body_bytes was set, and the
bytes were not counted against max_in_flight_bytes, since the handler
only wraps the body in its counting reader after validation.

Limit the read to 25 MiB when max_body_bytes is not set. This is at
least as large as the largest payload GitHub sends to webhooks, which
it caps at 25 MB. Larger bodies are rejected with a 413 before the
signature is checked. An explicit max_body_bytes keeps its existing
behaviour. When max_in_flight_bytes is set, count the buffered bytes
against it during validation and respond with a 503 and a Retry-After
header, as the handler does when the limit is exceeded while reading.
The in_flight value in that response is zero, since the bytes are
released when validation returns.

The request tracer reads the whole body of a rejected request to log
it. Limit that read to what is logged, so that rejecting an oversized
body does not buffer the rest of it.

HMAC requests with bodies larger than 25 MiB and no max_body_bytes were
previously accepted and are now rejected. The limit is per request;
max_in_flight_bytes is what limits the total.

(cherry picked from commit e178012)

Co-authored-by: Dan Kortschak <dan.kortschak@elastic.co>
efd6 added a commit that referenced this pull request Nov 13, 2026
…HMAC validation (#53937) (#54389)

When HMAC validation is configured, the whole request body is buffered
so that the signature can be checked and the body replayed to the
handler. That read had no limit unless max_body_bytes was set, and the
bytes were not counted against max_in_flight_bytes, since the handler
only wraps the body in its counting reader after validation.

Limit the read to 25 MiB when max_body_bytes is not set. This is at
least as large as the largest payload GitHub sends to webhooks, which
it caps at 25 MB. Larger bodies are rejected with a 413 before the
signature is checked. An explicit max_body_bytes keeps its existing
behaviour. When max_in_flight_bytes is set, count the buffered bytes
against it during validation and respond with a 503 and a Retry-After
header, as the handler does when the limit is exceeded while reading.
The in_flight value in that response is zero, since the bytes are
released when validation returns.

The request tracer reads the whole body of a rejected request to log
it. Limit that read to what is logged, so that rejecting an oversized
body does not buffer the rest of it.

HMAC requests with bodies larger than 25 MiB and no max_body_bytes were
previously accepted and are now rejected. The limit is per request;
max_in_flight_bytes is what limits the total.

(cherry picked from commit e178012)

Co-authored-by: Dan Kortschak <dan.kortschak@elastic.co>
efd6 added a commit that referenced this pull request Nov 13, 2026
…HMAC validation (#53937) (#54390)

When HMAC validation is configured, the whole request body is buffered
so that the signature can be checked and the body replayed to the
handler. That read had no limit unless max_body_bytes was set, and the
bytes were not counted against max_in_flight_bytes, since the handler
only wraps the body in its counting reader after validation.

Limit the read to 25 MiB when max_body_bytes is not set. This is at
least as large as the largest payload GitHub sends to webhooks, which
it caps at 25 MB. Larger bodies are rejected with a 413 before the
signature is checked. An explicit max_body_bytes keeps its existing
behaviour. When max_in_flight_bytes is set, count the buffered bytes
against it during validation and respond with a 503 and a Retry-After
header, as the handler does when the limit is exceeded while reading.
The in_flight value in that response is zero, since the bytes are
released when validation returns.

The request tracer reads the whole body of a rejected request to log
it. Limit that read to what is logged, so that rejecting an oversized
body does not buffer the rest of it.

HMAC requests with bodies larger than 25 MiB and no max_body_bytes were
previously accepted and are now rejected. The limit is per request;
max_in_flight_bytes is what limits the total.

(cherry picked from commit e178012)

Co-authored-by: Dan Kortschak <dan.kortschak@elastic.co>
@vishaangelova vishaangelova mentioned this pull request Nov 23, 2026
1 of 3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-8.19 Automated backport to the 8.19 branch backport-9.5 Automated backport to the 9.5 branch backport-9.6 Automated backport to the 9.6 branch bugfix Filebeat Filebeat Team:Security-Service Integrations Security Service Integrations Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants