-
Notifications
You must be signed in to change notification settings - Fork 136
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
more validation for containerName and blobKey to avoid access escape #203
Conversation
@@ -38,6 +38,8 @@ public void validate(String name) throws IllegalArgumentException { | |||
//blobkey cannot start with / (or \ in Windows) character | |||
if (name.startsWith("\\") || name.startsWith("/")) | |||
throw new IllegalArgumentException("Blob key '" + name + "' cannot start with \\ or /"); | |||
if (name.contains("../")) | |||
throw new IllegalArgumentException("Blob key '" + name + "' cannot contains ../"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
super nit
throw new IllegalArgumentException("Blob key '" + name + "' cannot contains ../"); | |
throw new IllegalArgumentException("Blob key '" + name + "' cannot contain ../"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some unit test that exercises this logic.
@@ -38,6 +38,8 @@ public void validate(String name) throws IllegalArgumentException { | |||
//blobkey cannot start with / (or \ in Windows) character | |||
if (name.startsWith("\\") || name.startsWith("/")) | |||
throw new IllegalArgumentException("Blob key '" + name + "' cannot start with \\ or /"); | |||
if (name.contains("../")) | |||
throw new IllegalArgumentException("Blob key '" + name + "' cannot contain ../"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this different than the container name validator? For robustness should this tokenize the path via /
then check each component to see if one contains .
or ..
? This would allow keys like ..foo
to work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think ..foo
should be allowed. I tried several object storage services, such as gcloud and aliyun oss, they all allow ..foo
as object key.
@@ -691,6 +698,8 @@ public BlobAccess getBlobAccess(String containerName, String blobName) { | |||
|
|||
@Override | |||
public void setBlobAccess(String container, String name, BlobAccess access) { | |||
filesystemContainerNameValidator.validate(container); | |||
filesystemBlobKeyValidator.validate(name); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this also apply to getBlobAccess
, putBlob
, and removeBlob
? getBlobKeysInsideContainer
too I guess.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These methods have been applied by the validators. I just added some missing ones.
@gaul Could you please review the new commits? |
Thank you for your contribution @jixinchi! |
No description provided.