Skip to content

packetbeat/protos/thrift: limit nesting depth of structs and collections - #54937

Open
efd6 wants to merge 1 commit into
elastic:mainfrom
efd6:s16657-packetbeat
Open

efd6 wants to merge 1 commit into
elastic:mainfrom
efd6:s16657-packetbeat

Conversation

@efd6

@efd6 efd6 commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Proposed commit message

packetbeat/protos/thrift: limit nesting depth of structs and collections

The parser followed nested structs, lists, sets and maps without any
limit. Each level of nesting costs only a few bytes on the wire, and
deeply nested values could overflow the goroutine stack. A stack
overflow is a fatal runtime error that recover cannot catch, so it
terminated the whole Packetbeat process rather than just the affected
stream.

Thread a depth through readStruct, readListOrSet and readMap, and
treat composite types beyond 64 levels as unknown so the stream is
dropped as a parse error. The limit matches the default recursion
limit of the Apache Thrift libraries. Add tests for each composite
type at the limit, just beyond it, and at a depth that overflows the
stack without the limit, plus a test through Parse. Document the
limit.

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

How to test this PR locally

Related issues

Use cases

Screenshots

Logs

The parser followed nested structs, lists, sets and maps without any
limit. Each level of nesting costs only a few bytes on the wire, and
deeply nested values could overflow the goroutine stack. A stack
overflow is a fatal runtime error that recover cannot catch, so it
terminated the whole Packetbeat process rather than just the affected
stream.

Thread a depth through readStruct, readListOrSet and readMap, and
treat composite types beyond 64 levels as unknown so the stream is
dropped as a parse error. The limit matches the default recursion
limit of the Apache Thrift libraries. Add tests for each composite
type at the limit, just beyond it, and at a depth that overflows the
stack without the limit, plus a test through Parse. Document the
limit.
@efd6 efd6 self-assigned this Nov 26, 2026
@efd6 efd6 added Packetbeat 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 Nov 26, 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 Nov 26, 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 Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

🔍 Preview links for changed docs

@github-actions

Copy link
Copy Markdown
Contributor

✅ Elastic Docs Style Checker (Vale)

No issues found on modified lines!


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.

@efd6
efd6 marked this pull request as ready for review November 26, 2026 04:31
@efd6
efd6 requested review from a team as code owners November 26, 2026 04:31
@infra-vault-gh-plugin-prod

Copy link
Copy Markdown

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

@mergify

mergify Bot commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue). If it does not match the queue conditions yet, it enters the queue once it does.

  • Queue this pull request once it meets the queue conditions

This branch was successfully deployed

1 active deployment
docs-preview — e3ee45aa Deployed Nov 26, 2026 by github-actions[bot]
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 Packetbeat Team:Security-Service Integrations Security Service Integrations Team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants