Skip to content

Commit

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

Fixes #6409

(cherry picked from commit a634802)
  • Loading branch information
adriansr authored and ruflin committed Jun 15, 2018
1 parent 36411a3 commit 49fbc32
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 @@ -41,6 +41,8 @@ https://github.com/elastic/beats/compare/v6.3.0...6.3[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 @@ -181,9 +181,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 49fbc32

Please sign in to comment.