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

Obfuscate stripe public key slightly to prevent trivial scraping #15

Open
rizend opened this issue Jun 24, 2019 · 6 comments
Open

Obfuscate stripe public key slightly to prevent trivial scraping #15

rizend opened this issue Jun 24, 2019 · 6 comments

Comments

@rizend
Copy link

rizend commented Jun 24, 2019

No description provided.

@marcidy
Copy link
Contributor

marcidy commented Aug 1, 2019

@rizend I'd like to have this in sooner than later. What do you think the best approach is?

@rizend
Copy link
Author

rizend commented Aug 2, 2019

I don't think there's any "best" approach; it's kind of a cat and mouse game and may not end up working. Initially, to prevent people just using a regex, I would split the key into multiple pieces, encode it, and obfuscate the stripe api call. E.g. instead of var stripe = Stripe.setPublishableKey("Hello World!");; maybe var stripe = this[atob("U3Rya"+atob("WEJs"))][atob("YXNldFB1Ymxpc2hhYmxlS2V5").substr(1)](atob(["SGVs", "G8gV29y", atob("R1Fo")].join("b")));

@marcidy
Copy link
Contributor

marcidy commented Aug 2, 2019 via email

@marcidy
Copy link
Contributor

marcidy commented Aug 4, 2019

thinking about this a bit.

how about server-side i send a nonce

Then the templates can do something like
var stripe = Stripe.setPublishableKey(get_key(nonce))
and I then invalidate that nonce once it is retrieved which should be like almost immediately?

request page
generate nonce
send page data + nonce
get_key(nonce)
send key
invalidate nonce's ability to retrieve further keys

will get key still turn into the private key? I can do the server side stuff i just dont know javascript well. I can figure it out if there isn't a readily available solution to retrieve data from a thing.

e.g. a route could be automatically created (/"nonce value") which checks if it's ever been hit before, and if so, returns nothing
I can store the nonce values in the db to see if it had been used before, assuming i use a good enough PRSG which i guess /dev/urandom would suffice.

@marcidy
Copy link
Contributor

marcidy commented Aug 4, 2019

I'm going to restart the discussion on the attackers on infrastructure repo. I think at a minimum we need fail2ban or similar no matter what. But it seems like they can just access the stripe front end values. Looking at the logs, I think the requests are being generated via the front-end on our servers, not just curl requests with the harvested public key. Was't clear last time since we didn't have ratchet logs.

@marcidy
Copy link
Contributor

marcidy commented Aug 4, 2019

nonce thing implemented in #34 while pending reCaptcha and fail2ban. will lexically obfuscate after testing this method, as that will now be easier to do as well.

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

No branches or pull requests

2 participants