Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parser hanging on stacked { tokens #90863

Closed
tonybaloney mannequin opened this issue Feb 10, 2022 · 4 comments
Closed

Parser hanging on stacked { tokens #90863

tonybaloney mannequin opened this issue Feb 10, 2022 · 4 comments
Labels
3.10 only security fixes 3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@tonybaloney
Copy link
Mannequin

tonybaloney mannequin commented Feb 10, 2022

BPO 46707
Nosy @tonybaloney, @lysnikolaou, @pablogsal
PRs
  • bpo-46707: Avoid potential exponential backtracking in some syntax errors #31241
  • [3.10] bpo-46707: Avoid potential exponential backtracking in some syntax errors (GH-31241). #31242
  • 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 = <Date 2022-02-10.03:54:55.013>
    created_at = <Date 2022-02-10.03:00:43.493>
    labels = ['interpreter-core', '3.10', 'type-crash', '3.11']
    title = 'Parser hanging on stacked { tokens'
    updated_at = <Date 2022-02-10.03:55:09.308>
    user = 'https://github.com/tonybaloney'

    bugs.python.org fields:

    activity = <Date 2022-02-10.03:55:09.308>
    actor = 'pablogsal'
    assignee = 'none'
    closed = True
    closed_date = <Date 2022-02-10.03:54:55.013>
    closer = 'pablogsal'
    components = ['Parser']
    creation = <Date 2022-02-10.03:00:43.493>
    creator = 'anthonypjshaw'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 46707
    keywords = ['patch', '3.10regression']
    message_count = 4.0
    messages = ['412972', '412974', '412975', '412976']
    nosy_count = 3.0
    nosy_names = ['anthonypjshaw', 'lys.nikolaou', 'pablogsal']
    pr_nums = ['31241', '31242']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'crash'
    url = 'https://bugs.python.org/issue46707'
    versions = ['Python 3.10', 'Python 3.11']

    @tonybaloney
    Copy link
    Mannequin Author

    tonybaloney mannequin commented Feb 10, 2022

    Providing an (invalid) input to the parser causes an exponentially-slow DoS to the Python executable in 3.10.

    e.g.

    python3.10 -c "{{{{{{{{{{{{{{{{{{{{{:"

    takes ~2 seconds

    python3.10 -c "{{{{{{{{{{{{{{{{{{{{{{{{:"

    takes ~22 seconds

    Tested this all the way up to
    d{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{{```{{{{{{{ef f():y

    which took over an hour

    @tonybaloney tonybaloney mannequin added interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump 3.10 only security fixes 3.11 only security fixes labels Feb 10, 2022
    @pablogsal
    Copy link
    Member

    New changeset b71dc71 by Pablo Galindo Salgado in branch 'main':
    bpo-46707: Avoid potential exponential backtracking in some syntax errors (GH-31241)
    b71dc71

    @pablogsal
    Copy link
    Member

    New changeset 9b23f8f by Pablo Galindo Salgado in branch '3.10':
    [3.10] bpo-46707: Avoid potential exponential backtracking in some syntax errors (GH-31241). (GH-31242)
    9b23f8f

    @pablogsal
    Copy link
    Member

    Thanks Anthony for the report!

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.10 only security fixes 3.11 only security fixes interpreter-core (Objects, Python, Grammar, and Parser dirs) type-crash A hard crash of the interpreter, possibly with a core dump
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant