Skip to content
This repository was archived by the owner on Nov 6, 2022. It is now read-only.
This repository was archived by the owner on Nov 6, 2022. It is now read-only.

Content-Length with obsolete line folding is accepted with invalid input #456

Closed

Description

@obatysh

According to https://tools.ietf.org/html/rfc7230#section-3.2.4
requests/responses with obsolete line folding can be rejected or obs-fold can be treated as one or more spaces.
obs-fold = CRLF 1*( SP / HTAB )

Currently any input after an obsolete line folding in Content-Length field would be accepted.
Example request:
"POST / HTTP/1.1\r\n"
"Content-Length: 42\r\n"
" ANY TEXT\r\n" // would be accepted and reported as part of Content-Length header field value
"\r\n"
...

Activity

  1. indutny commented on Dec 12, 2018

    @indutny
    Member

    I think this should yield HPE_UNEXPECTED_CONTENT_LENGTH error. Is there a test case that would demonstrate that it behaves differently?

    Thanks for reporting this!

  2. obatysh commented on Dec 12, 2018

    @obatysh
    Author

    There is no test yet, and it was reporting error before the commit 01da95f was introduced.

    The issue happens because after obsolete line folding is discovered the parser goes back to s_header_value_start. But as new content length states h_content_length_num, h_content_length_ws are not handled there it goes to default case and h_general state.

  3. indutny commented on Dec 12, 2018

    @indutny
    Member

    Thank you for checking it. Your analysis of the code path is absolutely correct! Did I understand it right, that after 01da95f the bug is no longer reproducible?

  4. obatysh commented on Dec 12, 2018

    @obatysh
    Author

    No, vice versa, the bug appears after
    01da95f

  5. indutny commented on Dec 12, 2018

    @indutny
    Member

    @obatysh would you care to clarify if this error is actually reproducible and you experienced it?

  6. indutny commented on Dec 12, 2018

    @indutny
    Member

    Nevermind, I can reproduce it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions