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

feat: encode store name + check for fetch #73

Merged
merged 3 commits into from
Oct 19, 2023

Conversation

eduardoboucas
Copy link
Member

URL-encodes the store name and throws an error message when a fetch implementation hasn't been found.

Closes https://github.com/netlify/pillar-runtime/issues/757.
Closes https://github.com/netlify/pillar-runtime/issues/756.

Verified

This commit was signed with the committer’s verified signature.
BurntSushi Andrew Gallant

Verified

This commit was signed with the committer’s verified signature.
BurntSushi Andrew Gallant
@eduardoboucas eduardoboucas requested a review from a team as a code owner October 19, 2023 14:31
@netlify
Copy link

netlify bot commented Oct 19, 2023

Deploy Preview for blobs-js ready!

Name Link
🔨 Latest commit 231386e
🔍 Latest deploy log https://app.netlify.com/sites/blobs-js/deploys/653147b94fadf10008f376e5
😎 Deploy Preview https://deploy-preview-73--blobs-js.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions github-actions bot added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Oct 19, 2023
Skn0tt
Skn0tt previously approved these changes Oct 19, 2023
@@ -33,7 +33,7 @@ export class Store {

constructor(options: StoreOptions) {
this.client = options.client
Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to scope options.name as well? I'm wondering what happens when name is set dynamically based on user input, and some attacker gets this to be deploy:foo. Then they can access a different store. If we also prefixed options.name, that wouldn't be possible

Copy link
Member Author

Choose a reason for hiding this comment

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

What would be the attack vector there? If you set the store name to deploy:<something>, you end up scoping your store to one of your deploys, which is basically the same as supplying a deploy ID in the constructor. It's not like you'll gain access to someone else's deploy?

I would be more in favour of adding a validation rule that prevents you from getting a store that starts with deploy:, because that's a reserved scope. Not that anything happens if you use it, but because it isn't the right flow.

Copy link
Contributor

Choose a reason for hiding this comment

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

What would be the attack vector there?

Imagine a site that stores some deploy-specific assets in deploy:id (don't know why, it's contrived), and then customer-specific assets in a store called :customer_id. Now a customer signs up with the slug deploy:foo, and 💥 their store clashes with the deploy-specific assets.

I would be more in favour of adding a validation rule that prevents you from getting a store that starts with `deploy:``

Yes, that sounds like a good fix!

Copy link
Member Author

Choose a reason for hiding this comment

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

Imagine a site that stores some deploy-specific assets in deploy:id (don't know why, it's contrived), and then customer-specific assets in a store called :customer_id. Now a customer signs up with the slug deploy:foo, and 💥 their store clashes with the deploy-specific assets.

With this PR, a store can't be called :customer_id, because we're URL-encoding it to %3Acustomer_id.

Copy link
Contributor

Choose a reason for hiding this comment

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

:customer_id was meant to be a placeholder for the customer ID

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think I've understood your example, but either way checking for the deploy: prefix is something we should do.

Done in 231386e.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've also URL-encoded the deploy ID for good measure. It shouldn't ever be needed, because deploy IDs are alphanumerical, but it just prevents someone doing weird things from triggering a request to a malformed URL.

Verified

This commit was signed with the committer’s verified signature.
BurntSushi Andrew Gallant
@eduardoboucas eduardoboucas merged commit 0cb0b36 into main Oct 19, 2023
@eduardoboucas eduardoboucas deleted the feat/more-improvements branch October 24, 2023 10:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants