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

Set permissions/ownership when creating a socket #94984

Open
Dreamsorcerer opened this issue Jul 18, 2022 · 5 comments
Open

Set permissions/ownership when creating a socket #94984

Dreamsorcerer opened this issue Jul 18, 2022 · 5 comments
Labels
topic-asyncio type-feature A feature request or enhancement

Comments

@Dreamsorcerer
Copy link
Contributor

Feature or enhancement

When creating a socket with one of the asyncio methods, it should be possible to specify the correct ownership/permissions needed for good security.

Pitch

When creating a server with loop.create_unix_server(), it will create the socket with default permissions which may lack security or may not be accessible to the application that is meant to communicate via this socket.

Previous discussion

python/asyncio#426

@Dreamsorcerer Dreamsorcerer added the type-feature A feature request or enhancement label Jul 18, 2022
@kumaraditya303
Copy link
Contributor

Can't you do this by calling os.chmod after binding the socket?

@Dreamsorcerer
Copy link
Contributor Author

Yes, see the original (archived) issue linked.

The behaviour is not desirable, and could potentially lead to security issues. If you can create a file with the correct permissions, why would you not be able to create a named socket with the correct permissions?

e.g. os.open allows setting the permissions on creation: https://docs.python.org/3/library/os.html#os.open

@gvanrossum gvanrossum added the 3.12 bugs and security fixes label Sep 30, 2022
@ezio-melotti ezio-melotti moved this to Todo in asyncio Sep 30, 2022
@gvanrossum
Copy link
Member

Possibly because there's no platform-independent way to do it? (I think I gleaned this from the original issue.)

Anyway, I'd be happy to review a PR, but I'm not the expert here. @Dreamsorcerer are you interested in submitting a PR?

@Dreamsorcerer
Copy link
Contributor Author

Not currently, got a hundred things to catch up on with aiohttp etc. Mainly just wanted to make sure the request didn't get lost. Maybe I'll get some time to come back to it at some point though.

@gvanrossum
Copy link
Member

No worries, hopefully someone else with relevant knowledge will help us out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-asyncio type-feature A feature request or enhancement
Projects
Status: Todo
Development

No branches or pull requests

4 participants