Skip to content
This repository has been archived by the owner on Oct 1, 2024. It is now read-only.

Prevent XSS attack using /auth/enable_cookies #1455

Merged

Conversation

@ghost ghost added the cla-needed label May 23, 2020
@ghost ghost removed the cla-needed label May 23, 2020
@@ -40,7 +40,7 @@ export default function createEnableCookies({

<script>
window.apiKey = "${apiKey}";
window.shopOrigin = "https://${shop}";
window.shopOrigin = "https://${encodeURIComponent(shop)}";

Choose a reason for hiding this comment

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

Should the https:// be part of the encodeURIComponent call as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i'm pretty sure "shop" always comes back as foo.myshopify.com

a couple years ago, @ragalie did this

3284be1#diff-a15b7c0928331371cc40785dd637c644R16

which is a different way of fixing this, in a different place

Copy link
Member

Choose a reason for hiding this comment

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

🤔 I think it's okay since we only want to encode the value coming from the user

Choose a reason for hiding this comment

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

That makes sense 👍

@@ -39,7 +39,7 @@ export default function createRequestStorageAccess({

<script>
window.apiKey = "${apiKey}";
window.shopOrigin = "https://${shop}";
window.shopOrigin = "https://${encodeURIComponent(shop)}";

Choose a reason for hiding this comment

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

Same thing here.

@seamusabshere
Copy link
Contributor Author

In general, I have a feeling that this PR is wrong.

The shop parameter should be checked as soon as it's received from the user, not every single time it's used.

@ricardotealdi
Copy link

The shop parameter should be checked as soon as it's received from the user, not every single time it's used.

Good point and I agree with you!

@jonpulsifer
Copy link
Contributor

jonpulsifer commented May 23, 2020

FYI @nhusher @seamusabshere we have a bug bounty program over at https://hackerone.com/shopify 💰 and there are rules for participation!

I am thinking of two rules in particular:

  • Rules for reporting must be followed.
  • Do not disclose any issues publicly before they have been resolved.

@jonpulsifer jonpulsifer merged commit dec3640 into Shopify:master May 23, 2020
@ragalie ragalie mentioned this pull request May 25, 2020
2 tasks
@alexandcote alexandcote temporarily deployed to production May 25, 2020 12:20 Inactive
@michenly michenly temporarily deployed to gem June 2, 2020 23:08 Inactive
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.
6 participants