Skip to content

[CVE-2024-9287] venv activation scripts do not quote strings properly #124651

Closed

Description

@y5c4l3

Bug report

Bug description:

Crafted paths break the script templates:

envname='";uname -a;"'
mkdir "$envname"
cd "$envname"
python3 -m venv .
. ./bin/activate
Linux archlinux 6.10.6-arch1-1 #1 SMP PREEMPT_DYNAMIC Mon, 19 Aug 2024 17:02:39 +0000 x86_64 GNU/Linux

Like pypa/virtualenv#2768 the execution path itself is low-risk, but it enables many potential downstream attack vectors. Downstream projects that automatically initialize and activate venv at a controllable path (e.g. read from repo configuration file) could execute unexpected commands.

CPython versions tested on:

3.8, 3.9, 3.10, 3.11, 3.12, 3.13, CPython main branch

Operating systems tested on:

Linux

Linked PRs

Activity

  1. added
    type-bug
    on Sep 27, 2024
  2. sethmlarson commented on Sep 27, 2024

    @sethmlarson
    Contributor

    Hey @y5c4l3, thanks for reporting this. We're going to treat this as a low-risk security issue. You or anyone else can submit a fix normally. If you have questions about this, send an email to security@python.org.

  3. y5c4l3 commented on Sep 27, 2024

    @y5c4l3
    ContributorAuthor

    @sethmlarson Thanks for the reply! Could you please help me with a code review for this PR as well as #124155? The code owner for venv seems to be unavailable recently.

  4. added a commit that references this issue on Oct 21, 2024
  5. added a commit that references this issue on Oct 21, 2024
  6. added a commit that references this issue on Oct 22, 2024
  7. gpshead commented on Oct 22, 2024

    @gpshead
    Member

    can we keep this open until all of the security branch backports are done?

  8. added a commit that references this issue on Oct 24, 2024
  9. added a commit that references this issue on Oct 30, 2024
  10. added
    topic-venv
    on Oct 30, 2024
  11. picnixz commented on Oct 30, 2024

    @picnixz
    Member

    We're going to treat this as a low-risk security issue

    Do you want to backport it up to 3.9 as well? If so, don't forget to add the backport labels on the PR (for now, we only have 3.12+)

  12. added a commit that references this issue on Oct 31, 2024
  13. 27 remaining items

  14. vstinner commented on Dec 13, 2024

    @vstinner
    Member

    Was this always the case? For example, venv with 3.12.7 and 3.12.6, aren't they compatible?

    It's a new issue caused by the security fix.

  15. added a commit that references this issue on Jan 12, 2025
  16. added 3 commits that reference this issue on Mar 6, 2025
  17. added a commit that references this issue on Mar 7, 2025
  18. added a commit that references this issue on Apr 9, 2025
  19. added a commit that references this issue on Apr 23, 2025
  20. added a commit that references this issue on Jul 4, 2025
  21. added a commit that references this issue on Aug 12, 2025
  22. deleted a comment from Outsideking on Sep 1, 2025
  23. added a commit that references this issue on Feb 3, 2026
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.10 (EOL)3.113.123.133.143.9 (EOL)topic-venvtype-bugtype-security

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions