Skip to content

Commit

Permalink
Fix out of bounds access in HTTP parser (elastic#6409) (elastic#6997)
Browse files Browse the repository at this point in the history
A broken HTTP request caused the parser to report a panic.

Fixes elastic#6409
  • Loading branch information
adriansr committed May 9, 2018
1 parent 0dd34b8 commit 966b38e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ https://github.com/elastic/beats/compare/v5.6.9...5.6[Check the HEAD diff]

*Packetbeat*

- Fix an out of bounds access in HTTP parser caused by malformed request. {pull}6997[6997]

*Winlogbeat*

==== Added
Expand Down
5 changes: 3 additions & 2 deletions packetbeat/protos/http/http_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,10 @@ func (*parser) parseHTTPLine(s *stream, m *message) (cont, ok, complete bool) {
m.method = common.NetString(fline[:afterMethodIdx])
m.requestURI = common.NetString(fline[afterMethodIdx+1 : afterRequestURIIdx])

if bytes.Equal(fline[afterRequestURIIdx+1:afterRequestURIIdx+len(constHTTPVersion)+1], constHTTPVersion) {
versionIdx := afterRequestURIIdx + len(constHTTPVersion) + 1
if len(fline) > versionIdx && bytes.Equal(fline[afterRequestURIIdx+1:versionIdx], constHTTPVersion) {
m.isRequest = true
version = fline[afterRequestURIIdx+len(constHTTPVersion)+1:]
version = fline[versionIdx:]
} else {
if isDebug {
debugf("Couldn't understand HTTP version: %s", fline)
Expand Down

0 comments on commit 966b38e

Please sign in to comment.