GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Possible resource exhaustation of `expandvars` in `Tools/freeze/checkextensions.py` · Issue #136073 · python/cpython

Possible resource exhaustation of expandvars in Tools/freeze/checkextensions.py #136073

New issue
Copy link
New issue
Copy link
Open
Open
Possible resource exhaustation of expandvars in Tools/freeze/checkextensions.py#136073
Copy link
Labels
3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixestriagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@kexinoh
kexinoh
opened on Jun 28, 2025
Issue body actions

Bug Description:
The code will re-scan the newly generated content after replacing the variable. If a variable is defined to contain itself (i.e., a recursive definition), this process will fall into infinite recursion.

This recursion can lead to two forms of attacks: one is to cause an infinite loop and deplete CPU resources, and the other is to cause the string to grow infinitely and deplete memory resources. The final result will all lead to the application crashing or being unresponsive.

Vulnerability Locations :
1.

cpython/Tools/freeze/checkextensions.py

Line 72 in e64395e

def expandvars(str, vars):

Repair Status:
None

Common Information:

  • CPython Version: main branch
  • Operating System: Linux
  • Credits: Finder is kexinoh (Xiangfan Wu) from QI-ANXIN Technology Research Institute.

Linked PRs

  • gh-136073: Fix expandvars() in Tools/freeze/checkextensions.py #136093

Activity

  1. kexinoh
    changed the title [-]Potential Quadratic Complexity Vulnerabilities in Tools Modules[/-] [+]Unbounded Resource Exhaustion Vulnerability in the Tool Module via Recursive Expansion[/+] on Jun 28, 2025
  2. picnixz
    changed the title [-]Unbounded Resource Exhaustion Vulnerability in the Tool Module via Recursive Expansion[/-] [+]Unbounded Resource Exhaustion Vulnerability in `Tools/freeze/checkextensions.py`[/+] on Jun 28, 2025
  3. picnixz
    added
    type-securityA security issueA security issue
    triagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    and removed
    type-securityA security issueA security issue
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Jun 28, 2025
  4. picnixz commented on Jun 28, 2025

    @picnixz
    picnixz
    on Jun 28, 2025
    Member
    More actions

    Ok, it actually affects freeze.py so I think we can backport it until 3.9. However, I haven't checked if this is a realistic attack

  5. StanFromIreland commented on Jun 28, 2025

    @StanFromIreland
    StanFromIreland
    on Jun 28, 2025
    Member
    More actions

    Out of curiosity, is freeze.py still maintained? The last update was 2 years ago and for this specific file 16.

  6. sobolevn commented on Jun 28, 2025

    @sobolevn
    sobolevn
    on Jun 28, 2025
    Member
    More actions

    Is it really a security issue? Tools/freeze is an internal tool, which is used when CPython is built. If someone can affect the building process - you have much bigger problems.

    I still think that this should be fixed, just doubting that this is a security issue.

  7. picnixz commented on Jun 28, 2025

    @picnixz
    picnixz
    on Jun 28, 2025
    Member
    More actions

    Although it's internal, it's still somehow documented: https://docs.python.org/3/faq/programming.html#how-can-i-create-a-stand-alone-binary-from-a-python-script. But I agree that it can be hard to exploit. I'm more worried about "mistakes" that can lead to issues.

  8. brianschubert commented on Jun 28, 2025

    @brianschubert
    brianschubert
    on Jun 28, 2025
    Contributor
    More actions

    Hmm, is triggering this even possible in practice? From what I understand this would require having a cyclic variable definition in a Setup file, but Make already detects variable cycles, so wouldn't building the module fail before this could be a problem? E.g. adding CC=$(CC) will cause Make to exit with *** Recursive variable 'CC' references itself (eventually). Stop..

  9. kexinoh commented on Jun 29, 2025

    @kexinoh
    kexinoh
    on Jun 29, 2025
    Author
    More actions

    I'm not quite clear about the specific construction process of make, but what I want to explain is that for

    a=$aa

    This situation can also cause problems, but there is no actual variable loop.

  10. serhiy-storchaka
    added a commit that references this issue on Jun 29, 2025

    pythongh-136073: Fix expandvars() in Tools/freeze/checkextensions.py

    82fcefa
  11. serhiy-storchaka commented on Jun 29, 2025

    @serhiy-storchaka
    serhiy-storchaka
    on Jun 29, 2025
    Member
    More actions

    Thank you for opening an issue @kexinoh. I wrote the patch yesterday, but needed an issue number for reference.

    I agree that this is a minor bug, and perhaps not exploitable. But it is worth to fix it. Unfortunately, there are no unit tests for all this code, so I cannot add new tests for this function. I tested it manually.

  12. serhiy-storchaka
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    3.13only security fixesonly security fixes
    3.14bugs and security fixesbugs and security fixes
    3.15bugs and security fixesbugs and security fixes
    and removed
    type-securityA security issueA security issue
    on Jun 29, 2025
  13. picnixz
    changed the title [-]Unbounded Resource Exhaustion Vulnerability in `Tools/freeze/checkextensions.py`[/-] [+]Possible resource exhaustation of `expandvars` in `Tools/freeze/checkextensions.py`[/+] on Jun 29, 2025
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

    3.13only security fixesonly security fixes3.14bugs and security fixesbugs and security fixes3.15bugs and security fixesbugs and security fixestriagedThe issue has been accepted as valid by a triager.The issue has been accepted as valid by a triager.type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402520 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.