R1D19 Moonshots Day 2; Clickjacking for the greater good.
On day two of my moonshot, I glue together all of the missing pieces to get the data to flow from pardot to inka.
Pardot allows you to inject arbitrary javascript into any form that you create. I used this to my advantage and basically stole the submit button event, temporarily sending data back to my own server for further processing (and eventual order input into inka.io) and then resubmitting the form as usual.
The code to get this to work on the JS side looks something like this:
(function() { var form = document.forms[0] function sendOrder(order, event) { xhr = new XMLHttpRequest(); xhr.open("POST", "https://$MY_SERVICE", true); xhr.setRequestHeader("Content-type": "application/json"); xhr.onreadystatechange = function() { if(xhr.readyState = XMLHttpRequest.DONE && xhr.status == 200) { event.target.submit(); } } xhr.send(order); } form.addEventListener("submit", function(event) { event.preventDefault(); // Code to Process Form sendOrder(order, event); } })();
The key thing to keep in mind is that if you do event.target.submit() before the XMLHTTPRequest finishes, then it may never process the full request. This is why we pass it into the function, and perform the resubmission of the form after the response has gone through.
This was a fun little hack, but the solution is far from perfect.
Problems
The biggest risk here is that anyone can submit this form now 10,000 times without any real checks in place. As much as we love our customers, we don't really want to send 10,000 T-shirts to spam bots.It’s also overly complex and the form parser is very jenky because it’s making some very poor assumptions about what this from will always look like. Since the form is ultimately generated by pardot, it is subject to change without notice at any time.
Further Improvements
Solving the first problem would be required before I felt comfortable having this live in production. Some ideas would be to do some rate limiting, or intelligent checking to verify that the form submission came form a real human being (perhaps counting the time that it took for them to fill out a form?)However any sort of javascript validation is error prone as we have seen in this lovely $170 Million mistake.
Another improvement would be to send an email to someone in the event that we were not able to process an order so that a human being could attempt to do it manually.
Despite some of theses setbacks, I was able to have pardot send from data to my laptop via ngrok, process the data, and automatically place a T-Shirt order on inka.io.
Thank you for reading! Share your thoughts with me on mastodon or via email.
Check out some more stuff to read down below.
Most popular posts this month
- Dagger Feels Like Magic
- Setting up ANTLR4 on Windows
- SQLite DB Migrations with PRAGMA user_version
- 20 Years of Ubuntu
- видно по глазам - you can see it in the eyes
Recent Favorite Blog Posts
This is a collection of the last 8 posts that I bookmarked.
- Serendipity from Armin Ronacher's Thoughts and Writings
- Andrea Veri: GNOME Infrastructure migration to AWS from Planet GNOME
- A Whale of a Time from https://popagandhi.com/
- Pluralistic: You should be using an RSS reader (16 Oct 2024) from Pluralistic: Daily links from Cory Doctorow
- Sahil Dhiman: 25, A Quarter of a Century Later from Planet Debian
- Reflections on Palantir from Nabeel S. Qureshi
- Reading Old Posts from Kev Quirk
- Capture less than you create from David Heinemeier Hansson
Articles from blogs I follow around the net
Script Doctoring
I’ve been having a number of communications problems in my interactions with my doctors at Kaiser lately, and it’s becoming one of those things where the burden and onus entirely is placed upon me to sort out, and that’s exhausting for the actually autist…
via Bix Dot Blog October 22, 2024Blockchain company Forte acquires games studios, demands secrecy, shuts them down
Sometime in 2023, blockchain firm Forte acquired game studios Phoenix Labs and Rumble Games. However, it would be a year before this came to light, because according to a report from Game Developer, Forte demanded secrecy from employ…
via Web3 is Going Just Great October 22, 2024Initial explorations of Anthropic's new Computer Use capability
Two big announcements from Anthropic today: a new Claude 3.5 Sonnet model and a new API mode that they are calling computer use. (They also pre-announced Haiku 3.5, but that's not available yet so I'm ignoring it until I can try it out myself.) Comp…
via Simon Willison's Weblog: Entries October 22, 2024Generated by openring