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

Write encrypted tags permission #486

Merged
merged 2 commits into from
Nov 10, 2016

Conversation

william-richard
Copy link
Contributor

I realized while doing some work on encrypted tags that, while we restrict which users are able to read encrypted tags, we do not restrict which users can write to them.

Depending on how you have built your automation around collins, this could have very bad consequences.

For example, if you automatically make server passwords match the password set in collins, using a configuration management tool that runs regularly like puppet or chef, an attacker that could not read the password could set it to a value they know, and then gain access or elevated permissions to your server.

This PR aims to fix this vulnerability by adding a canWriteEncryptedTags permission, that restricts which users are able to write encrypted tags.

It also renames canSeePasswords to canSeeEncryptedTags to better reflect what the permission does - you may have reasons to encrypt non-password attributes. It does this in a backwards compatible manner, so your existing permissions configs that use canSeePasswords should continue to function.

@tumblr/collins RFR

william-richard pushed a commit that referenced this pull request Nov 8, 2016
- Addition of canWriteEncryptedTags
- Renaming of canSeePasswords to canSeeEncryptedTags

Code PR: #486
Copy link
Contributor

@defect defect left a comment

Choose a reason for hiding this comment

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

Just minor comments. 👍

@@ -18,6 +18,7 @@ features {
useWhitelistOnRepurpose = true
keepSomeMetaOnRepurpose = [ attr1, attr2 ]
deleteSomeMetaOnRepurpose = [ attr4, attr3 ]
syslogAsset = tumblrtag1
Copy link
Contributor

Choose a reason for hiding this comment

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

This isn't directly related to this right? Just general clean up?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, I needed this to be able to see errors I was getting. so it is technically general cleanup, but since it was a one liner, I decided to sneak it in.

@@ -20,7 +20,29 @@ abstract class User(val username: String, val password: String) {
case false => None
}
def isEmpty(): Boolean = username.isEmpty && password.isEmpty && roles.isEmpty
def canSeePasswords(): Boolean = Permissions.please(this, Permissions.Feature.CanSeePasswords)
def canSeeEncryptedTags(): Boolean = {
// want to rename canSeePasswords to canSeeEncryptedTags
Copy link
Contributor

Choose a reason for hiding this comment

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

Picky, but this comment is a bit hard to decipher at first glance. Maybe something like

// We want to rename canSeePasswords to canSeeEncryptedTags but want to keep
// backward compatibility. So we use canSeeEncryptedTags if it is set, else fall
// back to canSeePasswords. 
// 
// Permissions default to true, so we also need to test if the permission is
// configured, and only use it if it is.

Will Richard added 2 commits November 8, 2016 12:50
Maintain backwards compatibility with feature.canSeePasswords though

Also, make this permission default to false if it is not set
@william-richard william-richard force-pushed the will-write-encrypted-tags-permission branch from 95d6938 to 88dface Compare November 8, 2016 17:50
@byxorna
Copy link
Contributor

byxorna commented Nov 8, 2016

Nice, LGTM. This should include some messaging in future release notes about backwards compatibility (or lack thereof) and provide a clear upgrade path.

@@ -123,6 +125,13 @@ class AssetLifecycle(user: Option[User], tattler: Tattler) {
opts.find(kv => restricted(kv._1)).map(kv =>
return Left(new Exception("Attribute %s is restricted".format(kv._1))))
}

opts.find(kv => Feature.encryptedTags.contains(kv._1)).map(kv =>
Copy link
Contributor

Choose a reason for hiding this comment

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

map really seems like the wrong since you don't care about the results only the side effect. perhaps foreach would more closely express what is happening

You might even put the writable and restricted tests into a single method since you use it in a few places

@william-richard william-richard merged commit ef74c4b into master Nov 10, 2016
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.

4 participants