Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.17](backport #42756) fix(x-pack/filebeat/input/http_endpoint): hmac header validation #42759

Merged
merged 1 commit into from
Feb 19, 2025

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Feb 18, 2025

Proposed commit message

The HMAC signature validation code had an optimization intended to
return early when the configured HMAC header was not present in the 
request. However, it was checking the wrong variable for emptiness,
which effectively skipped this check. If a request included an empty
HMAC header, the HMAC signature check would still proceed and fail due 
to the missing or incorrect signature.

This issue has been corrected by this commit. The code now returns
`errMissingHMACHeader` only when the header is truly absent (not present
rather than having an empty value). Additionally, before decoding the 
signature, a check for an empty value is added to return a descriptive error.

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
  • I have added an entry in CHANGELOG.next.asciidoc or CHANGELOG-developer.next.asciidoc.

Author notes

The problematic code is this section where on L67 it checks the value of v.hmacHeader which is from config instead of hmacHeaderValue which is from the request.

// Read HMAC signature from HTTP header.
hmacHeaderValue := r.Header.Get(v.hmacHeader)
if v.hmacHeader == "" {
return http.StatusUnauthorized, errMissingHMACHeader


This is an automatic backport of pull request #42756 done by [Mergify](https://mergify.com).

)

The HMAC signature validation code had an optimization intended to
return early when the configured HMAC header was not present in the
request. However, it was checking the wrong variable for emptiness,
which effectively skipped this check. If a request included an empty
HMAC header, the HMAC signature check would still proceed and fail due
to the missing or incorrect signature.

This issue has been corrected by this commit. The code now returns
`errMissingHMACHeader` only when the header is truly absent (not present
rather than having an empty value). Additionally, before decoding the
signature, a check for an empty value is added to return a descriptive error.

(cherry picked from commit a74865b)
@mergify mergify bot added the backport label Feb 18, 2025
@mergify mergify bot requested a review from a team as a code owner February 18, 2025 22:49
@botelastic botelastic bot added the needs_team Indicates that the issue/PR needs a Team:* label label Feb 18, 2025
@botelastic
Copy link

botelastic bot commented Feb 18, 2025

This pull request doesn't have a Team:<team> label.

@andrewkroh andrewkroh enabled auto-merge (squash) February 18, 2025 22:52
@andrewkroh andrewkroh merged commit 4d00574 into 8.17 Feb 19, 2025
23 checks passed
@andrewkroh andrewkroh deleted the mergify/bp/8.17/pr-42756 branch February 19, 2025 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport needs_team Indicates that the issue/PR needs a Team:* label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant