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 — gh-118486: Switch mkdir(mode=0o700) on Windows to use OWNER RIGHTS instead of CURRENT_USER by zooba · Pull Request #118515 · python/cpython

Conversation

@zooba

@zooba zooba commented May 2, 2024 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

This ensures directories created while elevated are not accessible by the same user when non-elevated.

  • Issue: [CVE-2024-4030] Enable mkdir(mode=0o700) to work on Windows #118486

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@zooba
pythongh-118486: Switch mkdir(mode=0o700) on Windows to use OWNER RIG…
77b83f4
…HTS instead of CURRENT_USER
@zooba zooba added the skip news label May 2, 2024
@zooba
zooba requested a review from eryksun May 2, 2024 17:12
@bedevere-app bedevere-app Bot added the awaiting core review label May 2, 2024
@bedevere-app bedevere-app Bot mentioned this pull request May 2, 2024
[CVE-2024-4030] Enable mkdir(mode=0o700) to work on Windows #118486
Closed
@zooba
zooba merged commit 8ed5466 into python:main May 2, 2024
@bedevere-app bedevere-app Bot removed the awaiting core review label May 2, 2024
@zooba
zooba deleted the gh-118486 branch May 2, 2024 18:43
eryksun
eryksun reviewed May 3, 2024
View reviewed changes
Comment thread Modules/posixmodule.c

int use_alias = 0;
DWORD cbSid = sizeof(data->sid);
if (!CreateWellKnownSid(WinCreatorOwnerRightsSid, NULL, (PSID)data->sid, &cbSid)) {

@eryksun eryksun May 3, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you prefer to use "CURRENT_USER", you could just move it to the end of the array. Then the SetEntriesInAclW() call would use a count of 2 or 3 depending on whether the current user is an elevated administrator. The latter is determined by querying TokenElevationType. For example:

    ULONG entry_count = 3;

    TOKEN_ELEVATION_TYPE elevation_type;
    DWORD return_length;
    if (GetTokenInformation(GetCurrentProcessToken(), TokenElevationType,
            &elevation_type, sizeof(elevation_type), &return_length) &&
        elevation_type == TokenElevationTypeFull)
    {
        entry_count = 2;
    }

GetCurrentProcessToken() returns the pseudohandle (HANDLE)-4, which has been supported since Windows 8.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@zooba zooba May 3, 2024

Copy link
Copy Markdown
Member Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, but I definitely don't want to try to detect anything about the user's current state. That feels brittle (e.g. if more things are added that ought to be detected).

OWNER RIGHTS is good, and it's actually what I tried to find first. The fallback is just for completeness - I don't expect CreateWellKnownSid to ever fail here, but at least if it does, we're probably not doing anything too bad.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
SonicField pushed a commit to SonicField/cpython that referenced this pull request May 8, 2024
@zooba @SonicField
pythongh-118486: Switch mkdir(mode=0o700) on Windows to use OWNER RIG…
abd0602
…HTS instead of CURRENT_USER (pythonGH-118515)
@hssyoo hssyoo mentioned this pull request Dec 17, 2024
OpenSSH incompatible with mkdir(mode=0o700) on Windows with OWNER RIGHTS #128038
Open
@coderabbitai coderabbitai Bot mentioned this pull request Aug 13, 2026
Lock the scratch ACL down on Windows where CPython's own mode handling is silently absent maximmasiutin/lockfile-sentinel#21
Merged
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@eryksun eryksun eryksun left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

skip news

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@zooba @eryksun
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — 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.