Skip to content

[security] CVE-2021-28861: http.server: Open Redirection if the URL path starts with // #87389

Closed

Description

@hamzaavvan
BPO 43223
Nosy @pfmoore, @vstinner, @tiran, @tjguk, @ned-deily, @ambv, @zware, @zooba, @hamzaavvan
PRs
  • bpo-43223: [SECURITY] Patched Open Redirection In SimpleHTTPServer Module #24848
  • Files
  • Capture.PNG
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = None
    created_at = <Date 2021-02-14.11:42:36.898>
    labels = ['type-security', 'deferred-blocker', '3.8', '3.9', '3.10', '3.11', '3.7', 'library']
    title = '[security] http.server: Open Redirection if the URL path starts with //'
    updated_at = <Date 2021-05-23.08:10:57.234>
    user = 'https://github.com/hamzaavvan'

    bugs.python.org fields:

    activity = <Date 2021-05-23.08:10:57.234>
    actor = 'hamzaavvan'
    assignee = 'none'
    closed = False
    closed_date = None
    closer = None
    components = ['Library (Lib)']
    creation = <Date 2021-02-14.11:42:36.898>
    creator = 'hamzaavvan'
    dependencies = []
    files = ['49808']
    hgrepos = ['404']
    issue_num = 43223
    keywords = ['patch']
    message_count = 5.0
    messages = ['386945', '387193', '387284', '390047', '394193']
    nosy_count = 9.0
    nosy_names = ['paul.moore', 'vstinner', 'christian.heimes', 'tim.golden', 'ned.deily', 'lukasz.langa', 'zach.ware', 'steve.dower', 'hamzaavvan']
    pr_nums = ['24848']
    priority = 'deferred blocker'
    resolution = None
    stage = 'patch review'
    status = 'open'
    superseder = None
    type = 'security'
    url = 'https://bugs.python.org/issue43223'
    versions = ['Python 3.6', 'Python 3.7', 'Python 3.8', 'Python 3.9', 'Python 3.10', 'Python 3.11']

    Linked PRs

    Activity

    1. changed the title [-][SECURITY] Open Redirection In Python 3.7 & 3.8[/-] [+][security] http.server: Open Redirection if the URL path starts with //[/+] on Feb 17, 2021
    2. added
      stdlibStandard Library Python modules in the Lib/ directory
      and removed on Feb 17, 2021
    3. changed the title [-][SECURITY] Open Redirection In Python 3.7 & 3.8[/-] [+][security] http.server: Open Redirection if the URL path starts with //[/+] on Feb 17, 2021
    4. hamzaavvan commented on Feb 19, 2021

      hamzaavvanmannequin
      MannequinAuthor

      As for the directory issue, not only .ssh but an attacker can use any directory to make the open redirection exploitable.

      And as for the HTTP Header Location, the server does not remove extra trailing slash from the PAYLOAD uri, which seems to be the cause of vulnerability getting exploited.

      http://127.0.0.1:8000//attacker.com/..%2f..%2f..%2f..%2f..%2f../%0a%0d/../.ssh

      So I believe the server should check for multiple slashes and remove them from the path.

      Additionally, as you've mentioned it should also prepend the host:port/ to the new_url variable before writing the HTTP Header Location because if an attacker bypasses the protection and add an extra slash the server will still redirect to the host which is getting inserted into the Location header. But honestly I need your opinion as concatenating host to the url may lead to Host Header Injection but it'll then require a different context.

      Please watch the POC video.
      POC Video: https://youtu.be/rLfOoEu1XXg

    5. ambv commented on Apr 2, 2021

      @ambv
      Contributor

      Deferred the blocker to a regular release due to lack of activity in time for the current expedited releases.

    6. added
      3.11only security fixes
      type-crashA hard crash of the interpreter, possibly with a core dump
      and removed on May 18, 2021
    7. changed the title [-][security] http.server: Open Redirection if the URL path starts with //[/-] [+][security] http.server: Open Redirection if the URL path starts with //racha999coperation[/+] on May 18, 2021
    8. added
      type-crashA hard crash of the interpreter, possibly with a core dump
      and removed on May 18, 2021
    9. changed the title [-][security] http.server: Open Redirection if the URL path starts with //[/-] [+][security] http.server: Open Redirection if the URL path starts with //racha999coperation[/+] on May 18, 2021
    10. changed the title [-][security] http.server: Open Redirection if the URL path starts with //racha999coperation[/-] [+][security] http.server: Open Redirection if the URL path starts with //[/+] on May 18, 2021
    11. added and removed
      type-crashA hard crash of the interpreter, possibly with a core dump
      on May 18, 2021
    12. changed the title [-][security] http.server: Open Redirection if the URL path starts with //racha999coperation[/-] [+][security] http.server: Open Redirection if the URL path starts with //[/+] on May 18, 2021
    13. added and removed
      type-crashA hard crash of the interpreter, possibly with a core dump
      on May 18, 2021
    14. hamzaavvan commented on May 23, 2021

      hamzaavvanmannequin
      MannequinAuthor

      Requested review for the unit test few days ago. Please check.
      #24848

    15. transferred this issue fromon Apr 10, 2022
    16. pablogsal commented on May 9, 2022

      @pablogsal
      Member

      ⚠️ This issue has been updated from 'deferred-blocker' to 'release blocker' as we are past beta1. This issue will block the next release (Python 3.11.0 beta 2). ⚠️

    17. self-assigned this
      on Jun 15, 2022
    18. gpshead commented on Jun 15, 2022

      @gpshead
      Member

      The PR mentioned above has what looks reasonable as a fix but is lacking a proper test. the reporter and PR author claims to have lost access to their github account. I'll pick this up.

    19. added a commit that references this issue on Jun 15, 2022
    20. gpshead commented on Jun 15, 2022

      @gpshead
      Member
    21. gpshead commented on Jun 16, 2022

      @gpshead
      Member

      there's no need for this to block a release, it's not a showstopper or regression. it's a known security issue. the blocking was to help it get attention. we've got attention happening now. :)

    22. added a commit that references this issue on Jun 21, 2022
    23. added 6 commits that reference this issue on Jun 21, 2022
    24. gpshead commented on Jun 21, 2022

      @gpshead
      Member

      fixed in main, 3.11, and 3.11. the remaining branches are up to the release managers. thanks!

    25. added 2 commits that reference this issue on Jun 22, 2022
    26. added a commit that references this issue on Jun 22, 2022
    27. ngie-eign commented on Oct 11, 2022

      @ngie-eign
      Contributor

      For the record, this reproduces on python 2.7 (I used wget --debug to confirm that the Location field was modified). I suspect that this also reproduces on python version <3.7.
      Just a note for others who might be supporting python versions <3.7 in OS distributions.

    28. vstinner commented on Oct 12, 2022

      @vstinner
      Member

      CVE-2021-28861 was assigned to this vulnerability.

    29. changed the title [-][security] http.server: Open Redirection if the URL path starts with //[/-] [+][security] CVE-2021-28861: http.server: Open Redirection if the URL path starts with //[/+] on Oct 12, 2022
    30. vstinner commented on Oct 12, 2022

      @vstinner
      Member

      I created https://python-security.readthedocs.io/vuln/http-server-redirection.html to track fixes of this vulnerability.

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

    Metadata

    Metadata

    Assignees

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions