Skip to content

The default .python-eggs mode doesn't satisfy pkg_resources's security check #254

@ghost

Description

Originally reported by: amluto (Bitbucket: amluto, GitHub: amluto)


$ rm ~/.python-eggs/ -rf
$ [anything that uses resource_filename on a zipped egg]
/usr/lib/python3.3/site-packages/pkg_resources.py:979: UserWarning: /home/username/.python-eggs is writable by group/others and vulnerable to attack when used with get_resource_filename. Consider a more secure location (set with .set_extraction_path or the PYTHON_EGG_CACHE environment variable).
  warnings.warn(msg, UserWarning)

The directory creation code appears to be:

#!python

            _bypass_ensure_directory(target_path)

in get_cache_path. _bypass_ensure_directory had a default mode of 0777 (!).

The check in _warn_unsafe_extraction_path is:

#!python

if mode & stat.S_IWOTH or mode & stat.S_IWGRP:
    [warn about it]

In other words, get_cache_path is, indeed, unsafe, and _warn_unsafe_extraction_path correctly warns about it.

Presumably get_cache_path should be fixed.

(This is a real security problem depending on a user's group and umask.)


Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions