CouchDB
  1. CouchDB
  2. COUCHDB-708

Newlines in document locations break header parsing

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: 0.10.1
    • Fix Version/s: 2.0.0
    • Component/s: Database Core
    • Labels:
      None
    • Environment:

      ubuntu

    • Skill Level:
      New Contributors Level (Easy)

      Description

      Newlines in document locations break header parsing. Potential header injection issues?

      $ curl -X DELETE http://localhost:5984/testdb

      {"ok":true}

      $ curl -X PUT http://localhost:5984/testdb

      {"ok":true}

      $ curl -i -X PUT -d '{}' 'http://localhost:5984/testdb/docid%0A'
      HTTP/1.1 201 Created
      Server: CouchDB/0.10.1 (Erlang OTP/R13B)
      Location: http://localhost:5984/testdb/docid

      Etag: "1-967a00dff5e02add41819138abb3284d"
      Date: Wed, 24 Mar 2010 12:33:25 GMT
      Content-Type: text/plain;charset=utf-8
      Content-Length: 70
      Cache-Control: must-revalidate

      {"ok":true,"id":"docid\n","rev":"1-967a00dff5e02add41819138abb3284d"}

        Activity

        Tim created issue -
        Tim made changes -
        Field Original Value New Value
        Description Newlines in document locations break header parsing. Potential header injection issues?

        curl -X DELETE http://localhost:5984/testdb
        curl -X PUT http://localhost:5984/testdb
        curl -i -X PUT -d '{}' 'http://localhost:5984/testdb/docid%0A'
        Newlines in document locations break header parsing. Potential header injection issues?

        $ curl -X DELETE http://localhost:5984/testdb
        {"ok":true}
        $ curl -X PUT http://localhost:5984/testdb
        {"ok":true}
        $ curl -i -X PUT -d '{}' 'http://localhost:5984/testdb/docid%0A'
        HTTP/1.1 201 Created
        Server: CouchDB/0.10.1 (Erlang OTP/R13B)
        Location: http://localhost:5984/testdb/docid

        Etag: "1-967a00dff5e02add41819138abb3284d"
        Date: Wed, 24 Mar 2010 12:33:25 GMT
        Content-Type: text/plain;charset=utf-8
        Content-Length: 70
        Cache-Control: must-revalidate

        {"ok":true,"id":"docid\n","rev":"1-967a00dff5e02add41819138abb3284d"}
        Hide
        Sean Bartell added a comment -

        Patch: properly urlencode this and other Location: headers.

        Show
        Sean Bartell added a comment - Patch: properly urlencode this and other Location: headers.
        Sean Bartell made changes -
        Attachment couchdb-urlencode-location.patch [ 12444840 ]
        Paul Joseph Davis made changes -
        Skill Level New Contributors Level (Easy)
        Hide
        Petr Běhan added a comment -

        Still a problem in current couchdb version (1.0.1 and svn head r1065575). I can confirm that the attached patch fixes the issue (after trivial rebase).

        Show
        Petr Běhan added a comment - Still a problem in current couchdb version (1.0.1 and svn head r1065575). I can confirm that the attached patch fixes the issue (after trivial rebase).
        Hide
        Jan Lehnardt added a comment -

        Looks good and simple, only needs a simple test case and this is ready to go.

        Show
        Jan Lehnardt added a comment - Looks good and simple, only needs a simple test case and this is ready to go.
        Robert Kowalski made changes -
        Assignee Robert Kowalski [ robertkowalski ]
        Hide
        ASF GitHub Bot added a comment -

        GitHub user robertkowalski opened a pull request:

        https://github.com/apache/couchdb/pull/275

        Add integration-test for newlines in location header

        COUCHDB-708

        You can merge this pull request into a Git repository by running:

        $ git pull https://github.com/robertkowalski/couchdb 708-newline-header

        Alternatively you can review and apply these changes as the patch at:

        https://github.com/apache/couchdb/pull/275.patch

        To close this pull request, make a commit to your master/trunk branch
        with (at least) the following in the commit message:

        This closes #275


        commit d150a8ea75eab63c8af0f4cbfd360e174d8d703a
        Author: Robert Kowalski <rok@kowalski.gd>
        Date: 2014-10-25T13:26:11Z

        Add integration-test for newlines in location header

        COUCHDB-708


        Show
        ASF GitHub Bot added a comment - GitHub user robertkowalski opened a pull request: https://github.com/apache/couchdb/pull/275 Add integration-test for newlines in location header COUCHDB-708 You can merge this pull request into a Git repository by running: $ git pull https://github.com/robertkowalski/couchdb 708-newline-header Alternatively you can review and apply these changes as the patch at: https://github.com/apache/couchdb/pull/275.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #275 commit d150a8ea75eab63c8af0f4cbfd360e174d8d703a Author: Robert Kowalski <rok@kowalski.gd> Date: 2014-10-25T13:26:11Z Add integration-test for newlines in location header COUCHDB-708
        Hide
        ASF GitHub Bot added a comment -

        GitHub user robertkowalski opened a pull request:

        https://github.com/apache/couchdb-chttpd/pull/7

        Fix location-header for documents with newlines in the name

        Properly urlencode the Document-Id in the Location-field of the
        header

        Based on a patch from Sean Bartell <wingedtachikoma@gmail.com>
        COUCHDB-708

        This patch is covered by tests in https://github.com/apache/couchdb/pull/275

        You can merge this pull request into a Git repository by running:

        $ git pull https://github.com/robertkowalski/couchdb-chttpd 708-newline-header

        Alternatively you can review and apply these changes as the patch at:

        https://github.com/apache/couchdb-chttpd/pull/7.patch

        To close this pull request, make a commit to your master/trunk branch
        with (at least) the following in the commit message:

        This closes #7


        commit b44515f1c137994f5278f42106ecf720e2c35011
        Author: Robert Kowalski <rok@kowalski.gd>
        Date: 2014-10-25T02:45:07Z

        Fix location-header for documents with newlines in the name

        Properly urlencode the Document-Id in the Location-field of the
        header

        Based on a patch from Sean Bartell <wingedtachikoma@gmail.com>
        COUCHDB-708


        Show
        ASF GitHub Bot added a comment - GitHub user robertkowalski opened a pull request: https://github.com/apache/couchdb-chttpd/pull/7 Fix location-header for documents with newlines in the name Properly urlencode the Document-Id in the Location-field of the header Based on a patch from Sean Bartell <wingedtachikoma@gmail.com> COUCHDB-708 This patch is covered by tests in https://github.com/apache/couchdb/pull/275 You can merge this pull request into a Git repository by running: $ git pull https://github.com/robertkowalski/couchdb-chttpd 708-newline-header Alternatively you can review and apply these changes as the patch at: https://github.com/apache/couchdb-chttpd/pull/7.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #7 commit b44515f1c137994f5278f42106ecf720e2c35011 Author: Robert Kowalski <rok@kowalski.gd> Date: 2014-10-25T02:45:07Z Fix location-header for documents with newlines in the name Properly urlencode the Document-Id in the Location-field of the header Based on a patch from Sean Bartell <wingedtachikoma@gmail.com> COUCHDB-708
        Hide
        ASF GitHub Bot added a comment -

        GitHub user robertkowalski opened a pull request:

        https://github.com/apache/couchdb-couch/pull/10

        Fix header for documents with newlines in the name

        Properly urlencode the Document-Id in the Location field of the
        header

        Based on a patch from Sean Bartell <wingedtachikoma@gmail.com>

        Added some eunit-tests

        COUCHDB-708

        You can merge this pull request into a Git repository by running:

        $ git pull https://github.com/robertkowalski/couchdb-couch 708-newline-header

        Alternatively you can review and apply these changes as the patch at:

        https://github.com/apache/couchdb-couch/pull/10.patch

        To close this pull request, make a commit to your master/trunk branch
        with (at least) the following in the commit message:

        This closes #10


        commit f58cbaa2e205342e619e34c59270d114943ec3d6
        Author: Robert Kowalski <rok@kowalski.gd>
        Date: 2014-10-25T01:16:38Z

        Fix header for documents with newlines in the name

        Properly urlencode the Document-Id in the Location field of the
        header

        Based on a patch from Sean Bartell <wingedtachikoma@gmail.com>

        Added some eunit-tests

        COUCHDB-708


        Show
        ASF GitHub Bot added a comment - GitHub user robertkowalski opened a pull request: https://github.com/apache/couchdb-couch/pull/10 Fix header for documents with newlines in the name Properly urlencode the Document-Id in the Location field of the header Based on a patch from Sean Bartell <wingedtachikoma@gmail.com> Added some eunit-tests COUCHDB-708 You can merge this pull request into a Git repository by running: $ git pull https://github.com/robertkowalski/couchdb-couch 708-newline-header Alternatively you can review and apply these changes as the patch at: https://github.com/apache/couchdb-couch/pull/10.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #10 commit f58cbaa2e205342e619e34c59270d114943ec3d6 Author: Robert Kowalski <rok@kowalski.gd> Date: 2014-10-25T01:16:38Z Fix header for documents with newlines in the name Properly urlencode the Document-Id in the Location field of the header Based on a patch from Sean Bartell <wingedtachikoma@gmail.com> Added some eunit-tests COUCHDB-708
        Hide
        ASF GitHub Bot added a comment -

        Github user robertkowalski commented on the pull request:

        https://github.com/apache/couchdb-couch/pull/10#issuecomment-60483108

        This commit is part of 3 commits to fix COUCHDB-708:

        https://github.com/apache/couchdb-couch/pull/10 (couchdb-couch)
        https://github.com/apache/couchdb/pull/275 (couch-db)
        https://github.com/apache/couchdb-chttpd/pull/7 (couchdb-chttpd)

        Show
        ASF GitHub Bot added a comment - Github user robertkowalski commented on the pull request: https://github.com/apache/couchdb-couch/pull/10#issuecomment-60483108 This commit is part of 3 commits to fix COUCHDB-708 : https://github.com/apache/couchdb-couch/pull/10 (couchdb-couch) https://github.com/apache/couchdb/pull/275 (couch-db) https://github.com/apache/couchdb-chttpd/pull/7 (couchdb-chttpd)
        Hide
        ASF GitHub Bot added a comment -

        Github user robertkowalski commented on the pull request:

        https://github.com/apache/couchdb/pull/275#issuecomment-60483124

        @kxepal no, not yet.

        This commit is part of 3 commits to fix COUCHDB-708:

        https://github.com/apache/couchdb-couch/pull/10 (couchdb-couch)
        https://github.com/apache/couchdb/pull/275 (couch-db)
        https://github.com/apache/couchdb-chttpd/pull/7 (couchdb-chttpd)

        Show
        ASF GitHub Bot added a comment - Github user robertkowalski commented on the pull request: https://github.com/apache/couchdb/pull/275#issuecomment-60483124 @kxepal no, not yet. This commit is part of 3 commits to fix COUCHDB-708 : https://github.com/apache/couchdb-couch/pull/10 (couchdb-couch) https://github.com/apache/couchdb/pull/275 (couch-db) https://github.com/apache/couchdb-chttpd/pull/7 (couchdb-chttpd)
        Hide
        ASF GitHub Bot added a comment -

        Github user robertkowalski commented on the pull request:

        https://github.com/apache/couchdb-chttpd/pull/7#issuecomment-60483128

        This commit is part of 3 commits to fix COUCHDB-708:

        https://github.com/apache/couchdb-couch/pull/10 (couchdb-couch)
        https://github.com/apache/couchdb/pull/275 (couch-db)
        https://github.com/apache/couchdb-chttpd/pull/7 (couchdb-chttpd)

        Show
        ASF GitHub Bot added a comment - Github user robertkowalski commented on the pull request: https://github.com/apache/couchdb-chttpd/pull/7#issuecomment-60483128 This commit is part of 3 commits to fix COUCHDB-708 : https://github.com/apache/couchdb-couch/pull/10 (couchdb-couch) https://github.com/apache/couchdb/pull/275 (couch-db) https://github.com/apache/couchdb-chttpd/pull/7 (couchdb-chttpd)
        Hide
        ASF subversion and git services added a comment -

        Commit b44515f1c137994f5278f42106ecf720e2c35011 in couchdb-chttpd's branch refs/heads/master from Robert Kowalski
        [ https://git-wip-us.apache.org/repos/asf?p=couchdb-chttpd.git;h=b44515f ]

        Fix location-header for documents with newlines in the name

        Properly urlencode the Document-Id in the Location-field of the
        header

        Based on a patch from Sean Bartell <wingedtachikoma@gmail.com>
        COUCHDB-708

        Show
        ASF subversion and git services added a comment - Commit b44515f1c137994f5278f42106ecf720e2c35011 in couchdb-chttpd's branch refs/heads/master from Robert Kowalski [ https://git-wip-us.apache.org/repos/asf?p=couchdb-chttpd.git;h=b44515f ] Fix location-header for documents with newlines in the name Properly urlencode the Document-Id in the Location-field of the header Based on a patch from Sean Bartell <wingedtachikoma@gmail.com> COUCHDB-708
        Hide
        ASF GitHub Bot added a comment -

        Github user asfgit closed the pull request at:

        https://github.com/apache/couchdb-chttpd/pull/7

        Show
        ASF GitHub Bot added a comment - Github user asfgit closed the pull request at: https://github.com/apache/couchdb-chttpd/pull/7
        Hide
        ASF subversion and git services added a comment -

        Commit 9ee298ff0af335f7449eca0f839caf0c5646887a in couchdb-couch's branch refs/heads/master from Robert Kowalski
        [ https://git-wip-us.apache.org/repos/asf?p=couchdb-couch.git;h=9ee298f ]

        Fix header for documents with newlines in the name

        Properly urlencode the Document-Id in the Location field of the
        header

        Based on a patch from Sean Bartell <wingedtachikoma@gmail.com>

        Added some eunit-tests

        COUCHDB-708

        Show
        ASF subversion and git services added a comment - Commit 9ee298ff0af335f7449eca0f839caf0c5646887a in couchdb-couch's branch refs/heads/master from Robert Kowalski [ https://git-wip-us.apache.org/repos/asf?p=couchdb-couch.git;h=9ee298f ] Fix header for documents with newlines in the name Properly urlencode the Document-Id in the Location field of the header Based on a patch from Sean Bartell <wingedtachikoma@gmail.com> Added some eunit-tests COUCHDB-708
        Hide
        ASF GitHub Bot added a comment -

        Github user robertkowalski closed the pull request at:

        https://github.com/apache/couchdb-couch/pull/10

        Show
        ASF GitHub Bot added a comment - Github user robertkowalski closed the pull request at: https://github.com/apache/couchdb-couch/pull/10
        Hide
        ASF subversion and git services added a comment -

        Commit 67f115e3ede1297d1a1086b321afc7fe424fdada in couchdb's branch refs/heads/master from Robert Kowalski
        [ https://git-wip-us.apache.org/repos/asf?p=couchdb.git;h=67f115e ]

        Add integration-test for newlines in location header

        COUCHDB-708

        Show
        ASF subversion and git services added a comment - Commit 67f115e3ede1297d1a1086b321afc7fe424fdada in couchdb's branch refs/heads/master from Robert Kowalski [ https://git-wip-us.apache.org/repos/asf?p=couchdb.git;h=67f115e ] Add integration-test for newlines in location header COUCHDB-708
        Hide
        ASF GitHub Bot added a comment -

        Github user robertkowalski closed the pull request at:

        https://github.com/apache/couchdb/pull/275

        Show
        ASF GitHub Bot added a comment - Github user robertkowalski closed the pull request at: https://github.com/apache/couchdb/pull/275
        Robert Kowalski made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Fix Version/s 2.0.0 [ 12315572 ]
        Resolution Fixed [ 1 ]
        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        1681d 10h 1m 1 Robert Kowalski 30/Oct/14 22:26

          People

          • Assignee:
            Robert Kowalski
            Reporter:
            Tim
          • Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development