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

improve security and fix a few minor issues #5

Merged
merged 4 commits into from
Apr 28, 2017

Conversation

pgerber
Copy link
Contributor

@pgerber pgerber commented Mar 31, 2017

Took a look at the default RNG used by the uuid crate and updated it while on it. I'm not a specialist for RNGs but a far as I can tell it should be strong enough that DoS are very unlikely to succeed. However, in the case of directories I decided to no longer recursively create the directory. When recursively creating it, "already exists" errors are ignored, potentially allowing an adversary to create the directory earlier than we do and thereby gaining full access to the directory. This would be far worse than DoS.

This is related to #3.

pgerber and others added 4 commits March 31, 2017 02:28
`DirBuilder` ignores if the directory already exists. This is a bit
of an isuse security-wise. An adversary could try to create the
directory first, giving her full access to our temporary directory.

Simply disabling the recursive mode appears to be the simplest and
most secure solution. Another possibilities might be to use a more
secury RNG (slower!) or implementing directory creation ourselves,
failing if the directory already exists.
If creation of a file or directory fails, the destructor panics
because the file doesn't exist.

Example:

// Temp instance is created here
let temp = Temp {
    path: create_path_in(directory.to_path_buf()),
    _type: TempType::Dir,
    _released: false,
};

// `Temp` is dropped here if creation the directory fails and the destructor
// will fail to remove the directory since its creation failed.
try!(temp.create_dir());
equalsraf added a commit to equalsraf/ffcli that referenced this pull request Apr 26, 2017
In windows trying to remove a file/directory being used may cause
an error - samgiles/rs-mktemp#5 will then
cause us to panic. For now leak the tmpdir and release early.
equalsraf added a commit to equalsraf/ffcli that referenced this pull request Apr 26, 2017
In windows trying to remove a file/directory being used may cause
an error - samgiles/rs-mktemp#5 will then
cause us to panic. For now leak the tmpdir and release early.
equalsraf added a commit to equalsraf/ffcli that referenced this pull request Apr 26, 2017
In windows trying to remove a file/directory being used may cause
an error - samgiles/rs-mktemp#5 will then
cause us to panic. For now leak the tmpdir and release early.
equalsraf added a commit to equalsraf/ffcli that referenced this pull request Apr 26, 2017
In windows trying to remove a file/directory being used may cause
an error - samgiles/rs-mktemp#5 will then
cause us to panic. For now leak the tmpdir and release early.
@samgiles samgiles merged commit bc7919a into samgiles:master Apr 28, 2017
@samgiles
Copy link
Owner

Very nice work, thanks! Will set up a release this evening. 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants