CASSANDRA-21389 trunk Harden snapshot names on server side#4826
CASSANDRA-21389 trunk Harden snapshot names on server side#4826smiklosovic wants to merge 4 commits into
Conversation
828d1ef to
b23b207
Compare
b23b207 to
394dc0d
Compare
Jollyplum
left a comment
There was a problem hiding this comment.
Had some minor nits but apart from that LGTM
| // 0-9 a-z A-Z ! - _ . * ' ( ) | ||
| // See https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html#object-key-guidelines | ||
| // Hyphen is placed last in the character class, so it stays literal and never becomes a range operator. | ||
| private static final Pattern SAFE_SNAPSHOT_NAME = Pattern.compile("[a-zA-Z0-9_.-]+"); |
There was a problem hiding this comment.
Part of me is wondering if we allow folks to configure the check off, maybe it may also make sense to allow them to configure what to restrict on?
Then if they encounter some character that they do actually validly need or can't change for some reason, operators can still benefit from some restrictions.
Debatable though maybe adds more configuration/reasoning complexity where we just want simplicity.
There was a problem hiding this comment.
we are complicating it too much imho with allowing them to do that, I think that is just premature as of now, they have a way to just completely remove the validation, that is good enough imho
| throw new RuntimeException("You must supply a snapshot name."); | ||
| throw new IllegalArgumentException("You must supply a snapshot name."); | ||
|
|
||
| if (tag.contains(File.pathSeparator())) |
There was a problem hiding this comment.
I think we may need to reject both the native path separator and '/' since on windows '\' is the path separator but '/' is still treated as a path separator, so in theory the path traversal attack remains on windows via that means.
There was a problem hiding this comment.
Actually potentially this is fine it seems we've remove windows support as of:
https://issues.apache.org/jira/browse/CASSANDRA-16171
https://issues.apache.org/jira/browse/CASSANDRA-16956
There was a problem hiding this comment.
we do not support Windows
88d8022 to
6220fbd
Compare
|
From the Alex's shallow/deep review, it seems we need to include |
|
one option is to only validate the snapshot names when the input is |
|
I played a little more with this PR, and I think we should add checks in While this has no effect at the moment, and I couldn't clear other snapshots, I think it's a good idea to fail with the validation. Also, I think we should explicitly tell users which characters are allowed when creating the snapshot. Here's the sample output from the create snapshot command We should instead say or something along those lines |
|
@frankgh no objections with more refined message with allowed chars and length but I am not sure about list/clear snapshot validation. It is overkill. In 6.0+, because it is on manager, we are literally checking snapshot name against user's argument. If it does not match then nothing is done. So it is irrelevant that a user wants to clear "../../abc", it will just filter snapshots with such a name - and since it is not possible to create a snapshot with a name like that this kind of a predicate always yields false, so nothing happens. I have pushed a commit called "Francisco review" with fixes. Please check again. |
6220fbd to
e151c46
Compare
e151c46 to
eb9d7c2
Compare
Thanks for sending a pull request! Here are some tips if you're new here:
Commit messages should follow the following format:
The Cassandra Jira