<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by @radekk on Medium]]></title>
        <description><![CDATA[Stories by @radekk on Medium]]></description>
        <link>https://medium.com/@radekk?source=rss-b6186669a1c5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*11x9via3DC-g6BDaGvOFig.png</url>
            <title>Stories by @radekk on Medium</title>
            <link>https://medium.com/@radekk?source=rss-b6186669a1c5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 29 Nov 2026 05:22:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@radekk/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[5 mistakes to avoid on the bug bounty program]]></title>
            <link>https://medium.com/@radekk/5-mistakes-to-avoid-on-the-bug-bounty-program-23af37228003?source=rss-b6186669a1c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/23af37228003</guid>
            <category><![CDATA[bugcrowd]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[hackerone]]></category>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[bug-bounty]]></category>
            <dc:creator><![CDATA[@radekk]]></dc:creator>
            <pubDate>Thu, 10 Nov 2022 07:02:34 GMT</pubDate>
            <atom:updated>2022-11-10T07:02:34.353Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*xJiHMTDM5_zG0Y7C" /><figcaption>Photo by <a href="https://unsplash.com/@cbpsc1?utm_source=medium&amp;utm_medium=referral">Clint Patterson</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Whether you are a bug bounty hunter or a pentester you should avoid fundamental mistakes. It’s all about efficiency and professionalism while growing your skills and striving for better results.</p><p>I’ve prepared a list of (5) the most common mistakes you should avoid when working on the bug bounty programs. It doesn’t matter if you operate on the HackerOne, BugCrowd or Synack platform as those rules are universal.</p><h4>1. Not doing your homework beforehand</h4><p>Before you even start you should be able to answer those three simple questions:</p><ol><li>What does the application do?</li><li>What is the scope of your test?</li><li>What are the deliverables you need to provide?</li></ol><p>In addition to all of the above, we can expand even further to end up having three categories to work on:</p><ol><li>Application’s mission and the business use-case (what it does? who are the users? what they do within the application?)<br>- Create a test account and get to know the application<br>- Read documentation if provided<br>- Identify the core components relaying on the authentication, authorization or processing sensitive data (PII)</li><li>Area or slice of the application we are going to test (specific API endpoints? admin panel? the entire application?)<br>- Create a list of assets (URLs, API endpoints, (sub)domains)<br>- Identify assets that are not publicly listed</li><li>What are you expected to provide as the result (is it a report? only a list of risks? engineering guidance?)<br>- Ensure that you read the policy and terms of service for both the bugbounty platform and program itself<br>- If it’s a pentest then you need a solid template for your report (<a href="https://github.com/juliocesarfort/public-pentesting-reports">examples</a>)<br>- Verify your list of assets with assets that are in the scope as stated by the specific program. Do not waste your time on assets that are out of scope.</li></ol><p>If you can address all of the points above then you’ve a solid plan and you are in a pretty good spot to start testing.</p><h4>2. Lack of respect</h4><p>You should know the limits. Whether it’s the bug bounty program or security assessment for a client you should always have an understanding on what you’re allowed to do and what are the restrictions. If there is a risk of exposing the personally identifiable information (PII) you should be really cautious since it might cause legal issues and you don’t want to get sued.</p><p>If you found a vulnerability and you believe that further exploitation would expose users data — <strong>STOP </strong>and contact your<strong> </strong>client/program directly to check if you can move forward.</p><p>It’s easy to get over-excited when you find a serious vulnerability in the system and you start acting irrationally trying different exploits or triggering shell commands. Do not be that guy from the <a href="https://news.ycombinator.com/item?id=10754194">“Instagram’s Million Dollar Bug”</a> — where Alex Stamos (back then CSO at Facebook) called researcher’s employer directly to report his shady activities.</p><p>You should <strong>always obey the rules</strong>. It’s better to be safe than sorry and always ask questions if you are unsure.</p><h4>3. Do not burn all of your findings at once</h4><p>It’s tempting to share a vulnerability right after you found a one. Think twice before you will do that as it may ruin your potential kill chain and reduce the final payout. You might be able to chain multiple vulnerabilities together.</p><p>If you locate an open redirect you might want to keep it and explore all of the system avenues before sending a report — you might find more. There is a great writeup from NahamSec where he described a similar scenario in the article “<a href="https://nahamsec.com/posts/chaining-multiple-vulnerabilities-to-gain-admin-access">Chaining multiple vulnerabilities to get admin access</a>”.</p><p>There is at least a one exception where I believe stacking up vulnerabilities is <strong>not</strong> a good idea. Whenever you find a <strong>critical</strong> bug that would be devastating for a client it might be better to share it right away and skip the process of building more advanced POC.</p><h4>4. Using default configuration for your tools</h4><p>Whenever you are using a new tool you should allocate some time to learn what features this tool does offer. You might be surprised how helpful some of them might be.</p><p>Just a few examples:</p><ul><li><strong>sqlmap</strong> — by default the HTTP user-agent header is set to sqlmap/1.0-dev-xxxxxxx (http://sqlmap.org) . It’s easily and often blocked by firewalls. Set the--random-agent option instead to use a legitimate browser string. [<a href="https://github.com/sqlmapproject/sqlmap/wiki/Usage#http-user-agent-header">ref</a>]</li><li><strong>nmap </strong>— it’s not only a network scanner but it’s capable of running scripts (<a href="https://nmap.org/book/nse-usage.html">NSE</a>) that could, e.g. check if target is affected by known vulnerabilities (<a href="https://securitytrails.com/blog/nmap-vulnerability-scan">nmap cve scan</a>)</li><li><strong>wfuzz</strong> — probably the most common fuzzer for the web, but not everyone knows that it comes with another tool called <a href="https://wfuzz.readthedocs.io/en/latest/user/wfpayload.html">wfpayload</a>. This tool is capable of analysing saved sessions or even run plugins on findings to do offline analysis.</li></ul><p>Do not throw random tools into the play praying that you will hit a jackpot. Always read the documentation as it might save you a lot of time in the future.</p><h4>5. Do not refuse to learn from the experience of others</h4><p>The 2020 <a href="https://itmoah.bugcrowd.com/">research from BugCrowd</a> says that:</p><blockquote>[…] 89% of security researchers use the details released to help find more critical issues in the same or similar programs […]</blockquote><p>You can learn a lot from previously disclosed reports including but not limited to new techniques, tools or even methodologies. If there are reports available from the program that you actively work on then it’s even better — learn, hack, repeat.</p><p>Is there anything you would add to this list? What is your experience with bug bounty programs so far? Let me know in the comments section and stay tuned for more content.</p><p><strong>Don’t forget to follow me on Twitter:</strong> <a href="https://twitter.com/radekk">https://twitter.com/radekk</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=23af37228003" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[picoCTF 2019 — JS Kiddie writeup (850 points)]]></title>
            <link>https://medium.com/@radekk/picoctf-2019-writeup-for-js-kiddie-7af4f0a20838?source=rss-b6186669a1c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/7af4f0a20838</guid>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[penetration-testing]]></category>
            <category><![CDATA[ctf]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[@radekk]]></dc:creator>
            <pubDate>Thu, 24 Oct 2019 10:31:26 GMT</pubDate>
            <atom:updated>2019-10-24T18:00:14.807Z</atom:updated>
            <content:encoded><![CDATA[<h3>picoCTF 2019 - JS Kiddie writeup</h3><p>The writeup for <strong>Script Kiddie 1</strong> and the <strong>Script Kiddie 2</strong> challenges</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*CXUVSrfYQfQ8P4Fi" /><figcaption>Photo by <a href="https://unsplash.com/@hidd3n?utm_source=medium&amp;utm_medium=referral">Kevin Horvat</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>The <a href="https://picoctf.com/">picoCTF</a> 2019 had a bunch of engaging challenges. I want to give you a brief overview on how I solved two of the web challenges —JS Kiddie 1 (<strong>400</strong> <strong>points</strong>) and JS Kiddie 2 (<strong>450</strong> <strong>points</strong>). What you might find interesting is that you could solve two challenges with the same code.</p><p>This challenge seemed to be a problematic one since not as many people solved it as did for other problems. In comparison, the easiest one was solved by over 21k people, whereas ~570 and 460 players solved JS Kiddie 1 and 2. It gives us <strong>less than 3%</strong> of all players that solved it.</p><h3>Java Script Kiddie 1</h3><p>The challenge web site contains two elements — the text input and the button. The source code of this page revealed that we were expected to provide the <strong>key</strong> to decrypt an image.</p><p>If you provide the invalid key, it will result in a corrupted image that will not render correctly in the browser. Whenever we give the valid key, we should see a correct PNG image.</p><h4>Understanding the source code</h4><p>To solve this challenge, you need to understand the source code first and find a way to either brute-force a key or build it up based on available data.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/a1c651ec54eaae9c8f05f28e68fc253a/href">https://medium.com/media/a1c651ec54eaae9c8f05f28e68fc253a/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ed70308fc4a0f5ac86d57b4a35fec269/href">https://medium.com/media/ed70308fc4a0f5ac86d57b4a35fec269/href</a></iframe><ul><li><a href="https://gist.github.com/radekk/54583a1f6ca2f6a5f234578f659cb944#file-pico-ctf-jskiddie1-html-L5-L8"><strong>Lines 5–8</strong></a><strong>:</strong> It sends a query to /bytes endpoint which returns numbers separated with space character. Then it’s being split up to create an array. The bytes variable stores bytes representing a (malformed) PNG image that you need to decrypt.</li><li><a href="https://gist.github.com/radekk/54583a1f6ca2f6a5f234578f659cb944#file-pico-ctf-jskiddie1-html-L10-L29"><strong>Lines 10–29</strong></a><strong>: </strong>The assemble_png(u_in) function takes a single argument which is the key (16 characters long) and then decrypts bytes array to restore an image and renders it on the page.</li><li><a href="https://gist.github.com/radekk/54583a1f6ca2f6a5f234578f659cb944#file-pico-ctf-jskiddie1-html-L18-L23"><strong>Lines 18–23</strong></a><strong>:</strong> The first loop iterates over every character from the key (left to right) and is setting up so called shiftervalue. The key.charCodeAt(i) — 48 code converts string into integer, i.e. &quot;5&quot; would be 53decimal as defined in the <a href="https://pl.wikipedia.org/wiki/ASCII">ASCII Table</a>, 53 — 48 = 5. It’s an <a href="https://stackoverflow.com/questions/27703166/how-to-convert-a-string-to-number-in-assembly-language-8086?rq=1">old trick</a> that was common in the assembly language. As a result it would convert string “123” into an array of [1 2 3] instead of [49 50 51]characters.</li><li><a href="https://gist.github.com/radekk/54583a1f6ca2f6a5f234578f659cb944#file-pico-ctf-jskiddie1-html-L20-L22"><strong>Lines 20–22</strong></a><strong>:</strong> The second loop is decrypting an image by splitting up bytesvalues into blocks of 16 bytes (key length). That would result in 720 bytes that gives 45 blocks (720 /16 = 45).</li><li><a href="https://gist.github.com/radekk/54583a1f6ca2f6a5f234578f659cb944#file-pico-ctf-jskiddie1-html-L21"><strong>Line 21:</strong></a> The output of decrypted image is stored in the result variable.</li></ul><p><strong>What do we know so far?</strong></p><ul><li>The first loop — 16 iterations over columns, the second loop — 45 iterations over rows</li><li>The total numbers of combinations for the 16 bytes key is 16¹⁰ — which is not really feasible for the brute-force attack</li></ul><p>To better understand and visualize the decryption process I created the visualization that should help you understand how bytes are decrypted (in this challenge the decryption process is based on re-ordering by adding the “shifter” value to a row number — different for each column). The first number in the key is our shifter value for the first column, then it takes the second number for the second column and so on.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YlS3IeSWv_1CYTZXCgECuw.gif" /><figcaption>The decryption process for the key of “4020000000000000” — using only first 288 bytes for demo purpose</figcaption></figure><h4>Reducing the number of combinations</h4><p>Instead of testing all of the 10¹⁶ combinations which doesn’t make much sense, I concentrated on decreasing the number of keys as much as possible. That would help to easily run through the defined set of combinations instead of blindly guessing they key.</p><p><strong>The PNG file format (first 8 bytes)</strong></p><p>One of the most important clues was hidden in the data:image/png fragment. It describes the PNG image where single bytes were encoded with base64.</p><pre>document.getElementById(&quot;Area&quot;).src = &quot;data:image/png;base64,&quot; + btoa(String.fromCharCode.apply(null, new Uint8Array(result)));</pre><p>The <a href="http://www.libpng.org/pub/png/spec/1.2/PNG-Structure.html">first 8 bytes of the PNG file</a> header were already known for this file format and it was: 0x89 0x50 0x4E 0x47 0x0D 0x0A 0x1A 0x0A (the PNG file header bytes — constant).</p><p><strong>Guessing the next 8 bytes</strong></p><p>The all provided bytes could be verified by using hexdump command in the terminal. Here is the example of printing out the PNG file bytes:</p><pre>$ hexdump -C test.png | head -n 2<br>00000000  89 50 4e 47 0d 0a 1a 0a  00 00 00 0d 49 48 44 52<br>00000010  00 00 0c 14 00 00 08 de  08 06 00 00 00 04 0f fc</pre><p>It seems that the rest of missing bytes consists of 0x00 0x00 0x00 0x0D 0x49 0x48 0x44 0x52. I wrote the bash one-liner to verify if those bytes are actually constant or at least the most common ones for the PNG file format. It scans through 100 different PNG files and extracts the first 16 bytes.</p><p><em>The other way of approaching this problem would be to read through RFC 2083 that describes the PNG file format. That would allow to get first 16 bytes without any guessing.</em></p><pre>$ for i in `seq 0 15`; do _png_byte=$(for file in *.png; do dd if=&quot;$file&quot; skip=$i bs=1 count=1 2&gt; /dev/null | hexdump -C | head -n 1 | awk &#39;{print $2}&#39;; done;); echo -n &quot;Position [${i}]: &quot;; echo -n &quot;${_png_byte}&quot; | sort | uniq -c | sort -rn | awk &#39;{print &quot;0x&quot;$2}&#39; | head -n 1; done;<br>Position [0]: 0x89<br>Position [1]: 0x50<br>Position [2]: 0x4e<br>Position [3]: 0x47<br>Position [4]: 0x0d<br>Position [5]: 0x0a<br>Position [6]: 0x1a<br>Position [7]: 0x0a<br>Position [8]: 0x00<br>Position [9]: 0x00<br>Position [10]: 0x00<br>Position [11]: 0x0d<br>Position [12]: 0x49<br>Position [13]: 0x48<br>Position [14]: 0x44<br>Position [15]: 0x52</pre><p><strong>What is next after decrypting the first 16 bytes of PNG file?</strong></p><p>The next step is to get each byte from the PNG file header (16 bytes) and locate it inside of the bytes variable. That would provide the shifter value for each byte. As a result you should’ve 16 shifter values which equals to the decryption key. The biggest challenge here is that there might be <strong>multiple positions for the same byte </strong>— it requires to test all of them if there is more than one.</p><p><strong>Brute-forcing bytes with the multiple valid positions</strong></p><p>I wrote the brute-force script to find and test valid positions for each byte from the PNG header. It occurs there are 4 bytes at offsets 2, 8, 9 and 10 where there is more than one valid position for a byte.</p><pre>More than one valid block for: 78 at 2 with count of 2 <br>More than one valid block for: 0 at 8 with count of 2 <br>More than one valid block for: 0 at 9 with count of 3 <br>More than one valid block for: 0 at 10 with count of 2</pre><p>Instead of manually testing for these values you can easily solve it by calculating the <a href="https://en.wikipedia.org/wiki/Cartesian_product">Cartesian product</a> to get all possible keys.</p><p><strong>I ended up reducing the number of combinations from 10¹⁶ to only 24 possible keys and here is the result:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qcATKkW2q8JjDoUiD_rAeQ.png" /><figcaption>Images generated by brute-force script, only one valid PNG file (QR code) — 24 images</figcaption></figure><p>To decode the QR Code image you can use <a href="https://zxing.org/w/decode.jspx">online qr-decoder</a>.</p><pre><strong>key: </strong>4549618526012495<br><strong>flag: </strong>picoCTF{cfbdafe5a65de4f32cce2e81e8c14a39}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XRIYQouNUMUyOEQ8snXv-A.png" /><figcaption>The result of visualization when using the valid key for decryption process</figcaption></figure><p>You can find the source code of my brute-force script here:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3947af8aa3ec60caa045b6a8e4b164ca/href">https://medium.com/media/3947af8aa3ec60caa045b6a8e4b164ca/href</a></iframe><h3>JavaScript Kiddie 2</h3><p>The JS Kiddie 2 challenge doesn’t differ much in regards to the first one. The same brute-force script will solve it. There are two major changes to the code of the second challenge:</p><p>The length of key variable is not 16 but 32 characters:</p><pre>var key = &quot;00000000000000000000000000000000&quot;;</pre><p>The shifter value formula is different than in the first one:</p><pre>shifter = Number(key.slice((i*2),(i*2)+1));</pre><p>What it does it uses <strong>every second</strong> byte from the key as actual key. It means that even though we have 32 characters, only 16 are being used.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5WSP2R7i7-hfZm9WMI-S8g.png" /><figcaption>Images generated by brute-force script, only one valid PNG file (QR code) —9 images</figcaption></figure><pre><strong>key</strong>: 3738193605318569<strong><br>flag: </strong>picoCTF{3aa9bd64cb6883210ee0224baec2cbb4}</pre><p>Thank you for reading and I hope you enjoyed it. Let me know in the comments if you have any questions or topics you would like me to write about.</p><p><strong>Don’t forget to follow me on Twitter:</strong> <a href="https://twitter.com/radekk">https://twitter.com/radekk</a></p><p><strong>Thanks!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7af4f0a20838" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to find vulnerabilities on OS X?]]></title>
            <link>https://medium.com/@radekk/how-to-find-vulnerabilities-in-hundreds-of-applications-8ffb97c89e9e?source=rss-b6186669a1c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ffb97c89e9e</guid>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[rce]]></category>
            <category><![CDATA[pentesting]]></category>
            <category><![CDATA[xxe]]></category>
            <dc:creator><![CDATA[@radekk]]></dc:creator>
            <pubDate>Sun, 15 Sep 2019 12:55:58 GMT</pubDate>
            <atom:updated>2019-09-15T12:58:56.183Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GBjovfitaYNlNc6MJsth2w.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@vorosbenisop?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Benjamin Voros</a> on <a href="https://unsplash.com/search/photos/mac?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>A while ago I did find a security vulnerability in hundreds of Mac OS X applications. It was a serious flaw in the updating process (RCE) — you could get hacked without even knowing that it happened.</p><p>I did a research on different updating strategies, and I tested a few applications working under Mac OS X. This research revealed that we had many insecure applications in the wild. As a result, I have found a vulnerability which allowed an attacker to take the control of another computer in the same network through the Man-in-the-middle (<a href="https://en.wikipedia.org/wiki/Man-in-the-middle_attack">MITM</a>) attack.</p><p>I’ve tested this issue on both OS X 10.10 (Yosemite) and 10.11 (El Capitan) with the latest version of the software, it should work with previous versions as well.</p><p>The vulnerability was <strong>not</strong> in code signing itself. It existed due to the functionality provided by the WebKit view that allows JavaScript execution and the ability to modify unencrypted HTTP traffic (XML response).</p><p>We have <strong>two different</strong> vulnerabilities here. First one is connected with the default configuration ( httpprotocol) which is not secure and leads to RCE (<em>Remote Code Execution</em>) over MITM attack in the untrusted environment.</p><p>The second one is the risk of parsing file://, ftp:// and other protocols inside the WebView component. As a result, if there is a security flaw on the server that allows replacing XML file, it can target all people through the affected application. It&#39;s possible even without knowing the private DSA key, without modifying application binary on the server and over https. After that, the MiTM attack is not a prerequisite anymore.</p><p><strong>The newest version of the Sparkle Updater is already available, and it addresses all of the vulnerabilities.</strong></p><h3>Which applications are affected?</h3><p>In short, all applications that used the <a href="https://sparkle-project.org/">Sparkle Updater</a> framework and were connecting over HTTP instead of a secure HTTPS connection. Since the Sparkle Framework throws an error in case of an invalid SSL certificate by default, it helps to protect against MITM attacks.</p><p>List of all applications using Sparkle Updater framework is huge since it is <strong>the most widely used framework</strong> available for OS X developers.</p><p>Example applications using Sparkle Updater:</p><ul><li><a href="https://adium.im/">Adium</a></li><li><a href="https://panic.com/coda/">Coda</a></li><li><a href="https://www.iterm2.com/">iTerm</a></li><li><a href="https://facebook.github.io/origami/update/">Facebook Origami</a></li><li><a href="http://www.sequelpro.com/">SequelPro</a></li><li><a href="https://tunnelblick.net/">Tunnelblick</a></li><li><a href="https://www.videolan.org/vlc/">VLC</a></li></ul><p>There are <a href="https://github.com/sparkle-project/Sparkle/issues/717">more</a>, but not all of them are vulnerable.</p><h3>Sparkle Updater</h3><p>The Sparkle Updater framework in its nature is safe and easy to use. Developers who include Sparkle in their projects just broke one simple rule: they did not set HTTPS everywhere.</p><p>The Sparkle Updater <a href="https://sparkle-project.org/documentation/#publish-your-appcast">documentation</a> notes:</p><blockquote><em>“We strongly encourage you to use HTTPS URLs for the AppCast.”</em></blockquote><p>Since downloading an application binary over HTTPS and using DSA signature for validation is quite common and most of the applications do that, there is still a tricky part called AppCast.</p><p>AppCast is the RSS feed that hosts information about our software updates, available versions and release notes. It’s the first URL that an application asks for when its update process starts. But what if the AppCast URL is using an unencrypted HTTP protocol?</p><h3>AppCast</h3><p>We cannot modify a binary on the fly without a key required for signing the application package. That is why using tools like <a href="https://github.com/secretsquirrel/BDFProxy">BDFProxy</a> is not going to work here because by changing a binary or replacing it with a different one you are going to break the DSA Signature validation process; Sparkle Updater returns an error.</p><p>If we cannot modify the binary file and we cannot update the DSA signature, does it sound like an impossible mission? Not really. Let’s take a look at this AppCast feature.</p><p><strong>Every time</strong> you want to release a new version of application you need to publish changes to your AppCast, just like with an RSS channel.</p><p>The official documentation of the Sparkle Updater project <a href="https://sparkle-project.org/documentation/publishing/#publishing-an-update">describes details of this process</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/723/0*M3wQnODxEuSr50Bc.png" /><figcaption>The Sparkle Updater — update process diagram</figcaption></figure><p>The AppCast request and response is using XML for the data exchange. The update notification message is just pure HTML code displayed inside a WebView component. In short it means that we have access to HTML and JavaScript which is enough to do some harm to the end user.</p><p>The description entity holds the entire update message to the user.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0fb3acf9ba0518351f46fee23b565ba4/href">https://medium.com/media/0fb3acf9ba0518351f46fee23b565ba4/href</a></iframe><h3>MiTM Attack</h3><p>Man In The Middle ( <a href="https://en.wikipedia.org/wiki/Man-in-the-middle_attack">MiTM</a>) is the attack where the third party secretly intercepts traffic between two parties, <em>e.g.</em>, a user and a server. It provides an opportunity to capture and modify (un)encrypted traffic from the user.</p><p>Let’s sum up everything we know so far:</p><ul><li>AppCast process is using HTTP that could be intercepted and modified on the fly</li><li>We can insert our HTML and JavaScript code into a WebView component to display it to the user</li><li>We control the transmission after doing the MITM attack</li></ul><p>With all this information, we can go further and start our attack against <a href="http://www.sequelpro.com/">SequelPro</a> (one of the affected applications). Let’s visualize actual network connections and components:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/830/0*wXu2EDYTACX2QEAy.png" /><figcaption>The Man-in-the-middle attack (MITM) — diagram</figcaption></figure><p>We control the unencrypted traffic from Bob’s machine by setting up one of the attacks inside your LAN, like fake Wi-Fi Access Point or sniffing/spoofing. Now we can spoof DNS probes for the AppCast server and send our malformed response which is:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/48f097c05bfe519b9bb282565d5e71e0/href">https://medium.com/media/48f097c05bfe519b9bb282565d5e71e0/href</a></iframe><p>Remember to bump-up the app version ( sparkle:version) in the XML response. Without it, SequelPro is not going to display our update reminder.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/0*wA5sCD3hXkHr59qA.png" /><figcaption>Sequel Pro — update modal window</figcaption></figure><p>After we’ve confirmed that HTML code get executed, we can test for the JavaScript example:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/62708f1550ed932f5d76e3741a125507/href">https://medium.com/media/62708f1550ed932f5d76e3741a125507/href</a></iframe><p>After checking for an update inside SequelPro app, Google website appears in our web browser, which means that the built-in WebView component executes JavaScript code.</p><p><strong>To sum up:</strong></p><ul><li>We have a working MiTM attack</li><li>We control JavaScript code executed on the client side (we can just open the user’s browser and redirect to a malicious website)</li></ul><h3>Abusing Webkit, WebView component</h3><p>This part is tricky. I tested many different solutions to exploit this WebView component, and failed many times. Matt just gave me a hint in his article <a href="http://maustin.net/hipchat_rce/"><em>XSS to RCE in Atlassian Hipchat</em></a>. It was the missing piece of the puzzle — executing the external application right from the WebView component.</p><p><strong>Before we exploit this issue we need to:</strong></p><ul><li>Set up the FTP server (our-fake-server.com) to host our malicious code</li><li>Run the HTTP server to act as an AppCast server</li><li>Redirect user traffic from the <a href="http://www.sequelpro.com/">www.sequelpro.com</a> website’s original IP address to our fake HTTP server</li></ul><p>When we are ready, we just need to replace our previous JavaScript snippet with modified code:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f0f487bcbb475f7abfd942f9d3b8a4f2/href">https://medium.com/media/f0f487bcbb475f7abfd942f9d3b8a4f2/href</a></iframe><p>Our UPGRADE.terminal file is an exported setting profile from the Terminal app (Terminal -&gt; Preferences -&gt; Profiles). Inside the &quot;Shell&quot; tab of selected profile, there is a possibility to add a startup command to execute immediately after loading a profile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/751/0*5c0PTcxmsqsT9_t3.png" /><figcaption>Mac OS X Terminal application — profile configuration, auto-run command</figcaption></figure><p>After our UPGRADE.terminal file is ready we can set up everything needed and start our attack. Remember that the user does not need to check for an update manually because applications do those checks periodically; it means that you can just wait for an appropriate update request from the app and then exploit it.</p><p><strong>This simple trick worked because:</strong></p><ul><li>When you are opening the external resource like FTP, SMB or AFP, then OS X is mounting it automatically under /Volumes/ path</li><li>We know the path to the resource because directory name is the same as the server name. As a result, we have the full path of /Volumes/our-fake-server.com/</li><li>We opened an app with the .terminal extension as a script. OS X is not looking for a signature/certificate and is not validating an app downloaded from the internet. It basically skips the <a href="https://en.wikipedia.org/wiki/Gatekeeper_(macOS)">Gatekeeper</a> validation.</li></ul><p>This vulnerability results in the <strong>Remote Code Execution</strong>.</p><h3>Abusing XML format</h3><p>There is also an additional attack that could be easily performed using the discovered vulnerability. Since communication is based on the XML format, we can test it against <a href="https://en.wikipedia.org/wiki/XML_external_entity_attack">XML External Entity (XXE) Processing</a> attack as well as <a href="https://en.wikipedia.org/wiki/Billion_laughs">Billion laughs</a> attack.</p><h3>Billion laughs</h3><p>Furthermore, we can enforce application to allocate much memory resources.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/88adb3f86d439d6b4eb3f1c555fb75a9/href">https://medium.com/media/88adb3f86d439d6b4eb3f1c555fb75a9/href</a></iframe><p>After running described attack using presented XML file, you can see that Sequel app is allocating <strong>3GB</strong> of memory. It means that our example worked well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/649/0*PeOSsWx11aDhmJ5w.png" /><figcaption>Successful billion laughs attack — using 3.5GB of memory</figcaption></figure><h3>XXE</h3><p>It is also possible to insert into the content of the update message any file located on the disk as far as SequelPRO can access it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/714784eb2110f62717d7a362adcab527/href">https://medium.com/media/714784eb2110f62717d7a362adcab527/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/0*VRD_tjYXXz5OCKSL.png" /><figcaption>Update modal — “/etc/passwd” file content</figcaption></figure><h3>XXE Out-Of-Band Data Retrieval</h3><p>The interesting thing about XXE vulnerability is that when SYSTEM entity is available, you could read files directly from the remote system. This entity is the simplest test for the XXE OOB attack.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d9f2b39949f7a487d697a3e70b11d20c/href">https://medium.com/media/d9f2b39949f7a487d697a3e70b11d20c/href</a></iframe><p>In that case, it is not working because there is an appropriate <a href="https://github.com/sparkle-project/Sparkle/blob/93a87a4dfd89fbb2fbfbda4b0835b7d04a31001d/Sparkle/SUAppcast.m#L105">fix</a> implemented for Sparkle framework. Sparkle Updater is free against XXE OOB attack.</p><h3>Video</h3><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F16acap5hep4%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D16acap5hep4&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F16acap5hep4%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e8c465b487df70da31814c179c713d20/href">https://medium.com/media/e8c465b487df70da31814c179c713d20/href</a></iframe><h3>Solution</h3><p>If you are curious if applications that you are running on your computer are affected by implementing the Sparkle Updater without https prefix, just run Wireshark and check it.</p><p>To fix and avoid RCE in your app, you need to edit Info.plist file and replace http -&gt; https for SUFeedURL key. Remember to check if your server configuration supports https and you have a valid SSL certificate in place.</p><p>To fully protect against this issue you need to upgrade the Sparkle Updater framework to the version 1.13.1 ( <a href="https://sparkle-project.org/">http://sparkle-project.org/</a>) which was already patched.</p><h3>Bounty from Facebook</h3><p><strong>Origami (Facebook)</strong> — I was talking with Zac. They fixed it immediately on the same day. Great communication and great process. I am glad that responsible people are working there. Afterwards I was awarded the $3k bounty from Facebook and I was added to their Hall of Fame list.</p><p><em>Originally published at </em><a href="https://vulnsec.com/2016/osx-apps-vulnerabilities/"><em>https://vulnsec.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ffb97c89e9e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5min Bash — sed]]></title>
            <link>https://medium.com/series/5min-bash-sed-f6fb6045c8cd?source=rss-b6186669a1c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/f6fb6045c8cd</guid>
            <dc:creator><![CDATA[@radekk]]></dc:creator>
            <pubDate>Sat, 14 Sep 2019 14:13:11 GMT</pubDate>
            <atom:updated>2019-09-14T14:43:42.888Z</atom:updated>
            <content:encoded><![CDATA[<h4>When you should use “sed” command?</h4><ul><li>Replacing text in files and stdin, i.e. “cat”, “echo” commands</li><li>Remove specific line(s) from a file</li><li>Replace text only on defined lines, it’s possible to specify a range as well, i.e. from 5th to 9th line</li><li>Processing hundreds or thousands of files easily, i.e. updating date and time, replacing your e-mail in all of your documents</li><li>Print out a specific line number from a file</li></ul><h4>[1/5] Basic usage</h4><ul><li><strong>sed</strong> [params] [cmd] [file(s)]</li><li><strong>cat</strong> file_path| sed [params] [cmd]</li><li><strong>echo</strong> “test” | sed [params] [cmd]</li></ul><p>Instead of text to replace you can provide a regular expression pattern (regexp). The biggest advantage of this command is that you can process dozens of files in a matter of milliseconds.</p><h4>[2/5] Useful parameters</h4><ul><li>(<strong>-E</strong>) use modern regular expressions</li><li>(<strong>-i </strong>ext) update file, extension name for backup files that “sed” creates when replacing content, i.e. (-i bak) “test.txt” =&gt; “test.txt.bak”. <strong>[warning]</strong> With empty parameter it will not create a copy of file after updating it.</li></ul><h4>[3/5] Replace text</h4><p>You need to be cautious when replacing text in files. Always remember to use (<strong>-i</strong>) parameter to create a copy of original file.</p><p><em>$&gt;</em> sed -i bak “s/foo/bar” test.txt</p><ul><li>Replace only the <strong>first</strong> occurrence of “foo” string inside “test.txt” file</li></ul><p><em>$&gt;</em> sed “s/foo/bar<strong>/g</strong>” test.txt</p><ul><li>Replace <strong>all</strong> occurrences…</li></ul><p><em>$&gt;</em> sed “s/foo/bar<strong>/2</strong>” test.txt</p><ul><li>Replace the <strong>second</strong> occurrence…</li></ul><p><em>$&gt;</em> sed “s/foo/bar<strong>/5g</strong>” test.txt</p><ul><li>Replace <strong>all </strong>occurrences starting with the 5th one…</li></ul><h4>[4/5] Removing lines</h4><p>Sed command allows to remove lines in a file that match a pattern or defined range.</p><p>$&gt; sed “10,50d” test.txt</p><ul><li>Remove lines <strong>from 10 to 50</strong> in a file</li></ul><p>$&gt; sed “10d” test.txt</p><ul><li>Remove the <strong>10th</strong> line from a file</li></ul><p>$&gt; sed “10,$d” test.txt</p><ul><li>Remove <strong>all</strong> lines from line 10th to the last line in file</li></ul><h4>[5/5] Takeaways</h4><ul><li>If there is no (<strong>-i</strong>) parameter specified then by <strong>default </strong>file content is printed back to the console. Without this parameter no changes are applied to the file</li><li>Sed can be used together with other commands, i.e. <a href="https://medium.com/series/5min-bash-grep-56a7d2693b8e">grep</a> or awk</li><li>To apply changes to more than one file you can use bash wildcards for file names, i.e. “/etc/*.conf” or “*.txt” (it would match all files with “.txt” extension)</li></ul><h3>More in 5min bash series</h3><ul><li><a href="https://medium.com/series/5min-bash-grep-56a7d2693b8e"><strong>grep </strong></a>— find for files with a specific text or print out only lines matching the regular expression pattern</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f6fb6045c8cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5min Bash — grep]]></title>
            <link>https://medium.com/series/5min-bash-grep-56a7d2693b8e?source=rss-b6186669a1c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/56a7d2693b8e</guid>
            <dc:creator><![CDATA[@radekk]]></dc:creator>
            <pubDate>Sat, 14 Sep 2019 13:59:45 GMT</pubDate>
            <atom:updated>2019-09-14T14:13:30.785Z</atom:updated>
            <content:encoded><![CDATA[<h4>When you should use “<strong><em>grep”</em></strong> command?</h4><ul><li>Searching for files with a specific text or regular expression pattern <em>(regexp)</em></li><li>Processing standard input in Bash (stdin), i.e. output from “cat”, “echo” commands</li><li>Finding files or lines from stdin that does NOT match a provided phrase or regexp <em>(inverse match [-v])</em></li><li>Searching inside compressed (gzip) files <em>(zgrep)</em></li></ul><h4>[1/5] Basic usage</h4><ul><li><strong>grep</strong> [params] [text] [directory]</li><li><strong>cat</strong> file_path| <strong>grep</strong> [params] [text]</li><li><strong>echo</strong> “test” | <strong>grep</strong> [params] [text]</li></ul><p>You can use aliases to avoid specifying additional parameters for extended regexp usage or gzip files, i.e.</p><ul><li><strong>e</strong>grep (-E, extended-regexp)</li><li><strong>z</strong>grep (-Z,-z, decompress)</li></ul><h4>[2/5] <strong>Useful parameters</strong></h4><ul><li>(<strong>-r</strong>) recursively search subdirectories</li><li>(<strong>-i</strong>) case insensitive matching</li><li>(<strong>-c</strong>) print out only a number of occurrences for each file or input text</li><li>(<strong>-v</strong>) inverse match [negation]</li><li>(<strong>-w</strong>) find only occurrences where provided text is a whole word</li></ul><h4>[3/5] <strong>Searching in files</strong></h4><p>Recursively searching in “/etc” path.</p><p><em>$&gt;</em> grep <strong>-ir</strong> “password“ /etc</p><ul><li>return files with “password” string</li></ul><p><em>$&gt;</em> egrep <strong>-ir</strong> “password[1–3]+” /etc</p><ul><li>return files with “password1”, “password2”, “password3” matches</li></ul><p><em>$&gt;</em> grep <strong>-irvw</strong> “password” /etc</p><ul><li>find all files where whole “password” word is not present. It would match “test password is” but not “testpassword is”</li></ul><h4>[4/5] <strong>Searching within stdin</strong></h4><p><em>$&gt;</em> echo “foobar” | egrep <strong>-i</strong> “BAR”</p><ul><li>foobar</li></ul><p><em>$&gt;</em> echo “foobar” | egrep <strong>-ic</strong> “BAR”</p><ul><li>1</li></ul><p><em>$&gt; </em>cat /etc/passwd | egrep “^root:”</p><ul><li>root:x:0:0:root:/root:/bin/bash</li></ul><h4>[5/5] Snippets</h4><p><em>$&gt;</em> egrep -rw “foobar” /etc | egrep -vw “password”</p><ul><li>Find all files with “foobar” word but without “password” word in the same line</li></ul><p><em>$&gt;</em> cat /etc/passwd | egrep -iv “^(root|admin):”</p><ul><li>Print all users except “root” and “admin”</li></ul><p><em>$&gt; </em>cat /etc/passwd | egrep -ic bash</p><ul><li>Count a number of occurrences for “bash” string in a file</li></ul><h3>More in 5min bash series</h3><ul><li><a href="https://medium.com/series/f6fb6045c8cd"><strong>sed </strong></a>— remove lines from file or replace text from stdin, single file or multiple files at once</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=56a7d2693b8e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hacking home routers from the Internet]]></title>
            <link>https://medium.com/@radekk/hackers-can-get-access-to-your-home-router-1ddadd12a7a7?source=rss-b6186669a1c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ddadd12a7a7</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[hacking]]></category>
            <category><![CDATA[router]]></category>
            <category><![CDATA[dns]]></category>
            <dc:creator><![CDATA[@radekk]]></dc:creator>
            <pubDate>Thu, 12 Sep 2019 07:01:01 GMT</pubDate>
            <atom:updated>2019-09-15T11:35:11.092Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zPQRyk1h0vUL5-JiupHMWg.jpeg" /><figcaption>Photo by <a href="https://unsplash.com/@webhost?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Web Hosting</a> on <a href="https://unsplash.com/search/photos/wifi-router?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></figcaption></figure><p>Securing your home router should be always the highest priority.</p><p>If you would like to understand how hackers can exploit your home router remotely even if you don’t have <em>Remote Management </em>option enabled and your device is <strong>not</strong> accessible from the Internet but only from the local network (LAN), this article is for you.</p><p>I’m going to describe the attack vector and exploitation process in details based on the<a href="https://nvd.nist.gov/vuln/detail/CVE-2016-6277"> CVE-2016–6277</a> vulnerability that was found in NETGEAR routers. This vulnerability allowed attackers to execute commands on the router as unauthenticated user.</p><p>If an attacker is able to execute commands directly on your router he can:</p><ul><li>Attack your internal network and other devices connected to it.</li><li>Backdoor the router installing malware or connecting it to the <a href="https://www.symantec.com/connect/blogs/mirai-what-you-need-know-about-botnet-behind-recent-major-ddos-attacks">Mirai Botnet</a>.</li><li>Eavesdrop on a user’s HTTP traffic.</li><li>Execute commands remotely on your router as a root user.</li><li>Shutdown or reboot your device.</li><li>Steal your Wi-Fi network credentials together with the network SSID (name).</li></ul><p>The attack surface is big enough to make a harm to a lot of home users and companies. I’ll describe some of those scenarios in details to show you how <strong>dangerous</strong> this vulnerability is.</p><h3>Sending remote commands</h3><p>Any attacker is able to issue a command on your router as a root user without your knowledge. It happens transparently, you only need to visit a malicious website. If you&#39;re not monitoring your outgoing connections it&#39;s not possible to detect this kind of activity without the additional tools.</p><p>The simplest payload to reboot the router of a person who visits your website:</p><p>Code is executed when image is loaded from the external server (your router). It doesn’t allow to get the response content but only trigger a command remotely.</p><h3>Reading data remotely from your router</h3><p>Issuing a remote command is not complicated since it doesn’t require to get the response content back to the attacker. Receiving a response back is not possible because of the <a href="https://tools.ietf.org/html/rfc6454">Same-Origin Policy [rfc #6454]</a> (SOP) restrictions.</p><p>The <strong>Same-Origin Policy</strong> is a security model for both browsers and plugins working in a browser (i.e. Java, Flash or Silverlight). The main purpose of this functionality is to block the access to the content of one website from the another website.</p><p>Access to the website content is granted depending on the <strong>origin</strong> that is specified for both of them. Truth table for origins looks as follow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4Qabyn4KYbjr3VR2NFznkg.jpeg" /><figcaption>The Same-Origin Policy (SOP) — comparing different scenarios</figcaption></figure><p><em>* — Port number is not included into “origin” component by IE/Edge browsers (</em><a href="https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy#IE_Exceptions"><em>more</em></a><em>).</em></p><p>If the website “A” doesn’t have the same origin as website “B” then it means that we <strong>cannot</strong> read the content of a website “B” from “A” and back. We’re assuming that the <a href="https://www.w3.org/TR/cors/">Cross-Origin Resource Sharing (CORS)</a> is not enabled for any server, which is true for the default configuration.</p><p>Router device doesn’t have the same origin as attacker’s website. Nevertheless the attacker can achieve that communication with techniques for <strong>bypassing</strong> the Same-Origin policy. There were even vulnerabilities in the SOP mechanism itself:</p><ul><li><a href="https://www.mozilla.org/en-US/security/advisories/mfsa2015-122/">CVE-2015–7188</a> — <em>Trailing whitespace in IP address hostnames can bypass same-origin policy.</em></li><li><a href="https://www.mozilla.org/en-US/security/advisories/mfsa2016-29/">CVE-2016–1967</a> — <em>Same-origin policy violation using performance.getEntries and history navigation with session restore.</em></li><li><a href="https://www.mozilla.org/en-US/security/advisories/mfsa2016-13/">CVE-2016–1949</a> — <em>Same-origin policy violation using Service Workers with plugins.</em></li></ul><p>Bypassing the Same-Origin Policy is possible by exploiting vulnerable browser/plugin or by using the technique called <a href="https://en.wikipedia.org/wiki/DNS_rebinding">DNS Rebinding</a>.</p><h4>DNS Rebinding attack</h4><p>DNS Rebinding attack allows to read data from the another origin bypassing the Same-Origin Policy mechanism. In the most basic scenario it’s possible to replace the DNS record (“A”) of a domain while user is visiting the malicious website.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3gXfNM9B9w-YzptGWFqteA.png" /><figcaption>DNS Rebinding — diagram</figcaption></figure><p>If this attack was successful then attacker is able to read any response from a command executed on the remote router ( 192.168.1.1).</p><h4>Sensitive data on the router side</h4><p>Attacker is now able to read the remote content from your router. He can issue a nvram show command which holds all configuration settings of your router like:</p><pre>wl0_ssid=&lt;your_wifi_ssid_in_plaintext&gt;<br>wla_secu_type=WPA2-PSK<br>wla_passphrase=&lt;your_wifi_password_in_plaintext&gt;<br>http_username=admin<br>http_passwd=&lt;web_gui_password&gt; ...</pre><p>Mentioned command returns a lot of sensitive data. Attacker is not only able to <strong>read data</strong> from the router but he can also <strong>set new values</strong> for those settings. It means that he is able to:</p><ul><li>Change your Wi-Fi password.</li><li>Turn On remote management (<a href="http://kb.netgear.com/976/Enabling-your-router-s-remote-management">netgear.com — documentation</a>).</li><li>Disable firewall.</li><li>Setup VPN to his desired location.</li><li>Update nvram settings, it will load saved settings after device restart (nvram set http_passwd=test; nvram commit).</li><li>…and much more.</li></ul><h3>How to protect against those kind of attacks?</h3><p>There is no single easy method to protect against all variants of this attack. I would recommend to disable httpd daemon on the router and block all incoming connections to your LAN from the Internet.</p><h3>Protect against DNS Rebinding attack.</h3><p>The standard protection mechanism on the server side is to check the Host header. In a standard scenario when your browser connects to facebook.com then it sends Host: facebook.com header.</p><p>If there is the <em>DNS Rebinding</em> attack in place and user visits attacker.com which tries to exploit SOP mechanism then browser connects to facebook.com and sends Host: attacker.com header. If server is configured properly then should block this request since Host header doesn&#39;t match the original request.</p><p>Netgear router <strong>is not blocking</strong> the connection even if Host header is invalid and therefore this attack succeed, which is true for most of the routers.</p><h3>Block connection to your LAN from the Internet.</h3><p>The easiest method is to block ALL connections from the Internet to your local network. It will block any kind of communication from the Browser to your local devices like router and other computers.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/0*VIBq8HQeHwU9YU4o.png" /></figure><p>For everyone working on Mac OS X it’s possible to install <a href="https://www.obdev.at/products/littlesnitch/index.html">Little Snitch</a> application which is able to restrict the access to defined subnets or specific IP addresses for every application or system process.</p><p>Another way is to use dnsmasq daemon to block connections to your private address space. Check manual at <a href="https://linux.die.net/man/8/dnsmasq">https://linux.die.net/man/8/dnsmasq</a> for --stop-dns-rebind parameter.</p><p>Fixing this issue will not only protect you against this exploitation technique but also against future threats based on the <em>DNS Rebinding</em> attack.</p><p><em>Originally published at </em><a href="https://vulnsec.com/2016/how-routers-are-exploited-remotely/"><em>https://vulnsec.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ddadd12a7a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Puzzle hidden in the book]]></title>
            <link>https://medium.com/@radekk/hacking-a-book-i-found-a-flag-44c2f841d0c1?source=rss-b6186669a1c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/44c2f841d0c1</guid>
            <category><![CDATA[riddles]]></category>
            <category><![CDATA[infosec]]></category>
            <category><![CDATA[book-review]]></category>
            <category><![CDATA[writeup]]></category>
            <category><![CDATA[puzzle]]></category>
            <dc:creator><![CDATA[@radekk]]></dc:creator>
            <pubDate>Tue, 10 Sep 2019 07:01:01 GMT</pubDate>
            <atom:updated>2020-11-11T19:44:35.388Z</atom:updated>
            <content:encoded><![CDATA[<h3>Puzzle hidden in a book</h3><p>The full title of this polish book is “Praktyczna inżynieria wsteczna” which we can translate to “Applied Reverse Engineering”. The editorial board was <a href="https://twitter.com/gynvael">Gynvael Coldwind</a> and <a href="https://twitter.com/j00ru">Mateusz Jurczyk</a>. A lot of great people actually helped to create this book by writing articles, check it out.</p><p>Full details about that book: <a href="http://ksiegarnia.pwn.pl/Praktyczna-inzynieria-wsteczna,622427233,p.html">PWN bookstore</a></p><p>Gynvael mentioned my solution on his <strong>livestream</strong> (starts around <strong>10:40</strong>): <a href="https://youtu.be/wJxWBeHWnGQ?t=640">https://youtu.be/wJxWBeHWnGQ?t=640</a></p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FwJxWBeHWnGQ%3Fstart%3D640%26feature%3Doembed%26start%3D640&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DwJxWBeHWnGQ&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FwJxWBeHWnGQ%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a5e8faa3d215280427264bf1099d2c7/href">https://medium.com/media/7a5e8faa3d215280427264bf1099d2c7/href</a></iframe><p>Book cover (take into account that the original book cover you can find on the Internet is different [without an assembly code] than this final one):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/0*EzrJGyxGdWPPV-tX.png" /></figure><h3>Recovering a code</h3><p><strong>Tools/Helps:</strong></p><ul><li><a href="http://www.felixcloutier.com/x86/">x86 instructions</a> — List of Assembly instructions on x86</li><li><a href="https://www.kali.org/downloads/">Kali Linux 32bit</a> — Linux distributions with variety of tools</li><li><a href="https://github.com/eteran/edb-debugger">EDB</a> — x86 debugger (Pre-installed on Kali Linux)</li><li><a href="http://www.nasm.us/">NASM</a> — Assembly compiler (Pre-installed on Kali Linux)</li></ul><p>Before we start analysing anything we need to copy the hex bytes and assembly code from a book cover. I recreated those bytes manually in a text editor without using any kind of OCR tool, it was the fastest method since we need to do that only once. No need for automation here.</p><p><strong>HEX bytes:</strong></p><pre>ad524552450fc6bf40638c638503cfc648cb455245d697264da04a6ab59004b9a80b7cd6c86f455245274913c5ab52279fea023d2a3689ea0b1d1517899cd11f13d73c1a13b4233b886a10493ce5fa92f8c1b099cbf0810083a5aef1d1ccf121634c36a5cc16ae9377d1b5d43d16feb017f8baaf820845ab2cfe0615a576d07001336c51ad4c4a91c9f19b1e4dff941aae12d2d2d508687ba1063026243812222c213f0624382b370d33363e2a7364734552000</pre><p>How do I know that bytes from a book cover are actually hexadecimal pairs? There are a few indicators that confirm my theory:</p><ul><li>Only valid HEX characters within a range <strong>A-F</strong> and <strong>0–9</strong>.</li><li>If you split the whole string into pairs of 2-bytes each you will get HEX encoded values like 0xAD, 0x52 ...</li><li>A length of this string is actually 359 bytes and it doesn’t divide by 2 (359 % 2 !== 0) which means 358th is the last valid pair of 2-bytes and the next value is a <strong>single</strong> character. Nevertheless it doesn’t matter here, look at 3 last bytes which are 000, last valid HEX is 0x00 and one additional character is just a <strong>padding</strong> value to make a book cover look right.</li></ul><p><strong>Assembly code:</strong></p><p>The full code that is ready to compile is here: <a href="https://gist.github.com/radekk/e4f3708c58bafd1a0f0b59d96a0877db">Pseudo code from a book cover ported to NASM · GitHub</a></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8120e3a6d886c91bc06b9e1cca4c343c/href">https://medium.com/media/8120e3a6d886c91bc06b9e1cca4c343c/href</a></iframe><p>At first when I looked at this snippet I thought it’s just a random assembly code but then I tried to expand those acronyms like [bk_cvr] and [rwx_mem].</p><ul><li><strong>bk_cvr</strong> — it expands to <strong>book cover</strong></li><li><strong>rwx_mem</strong> — here is a <strong>memory</strong> with access rights to <strong>r</strong>ead, <strong>w</strong>rite, e<strong>x</strong>ecute (rwx).</li></ul><p>This assembly fragment executes from top to the bottom:</p><ol><li>Assign to ESI register an address to HEX bytes from a book cover.</li><li>Assign to EDI register an address of the allocated memory space where we can put our decoded bytes.</li><li>Set the value of ECX register to 89 (decimal).</li><li>Set a label called “dcd” so we can reference to it from a loop or JMP directives (like with a label for goto directive).</li><li>lodsw — Load word at address defined by ESI (hex character from a book cover) into AX register. After a first iteration EAX = 0x000052ad.</li><li>XOR value in AX register with 0x5245 (AX = 0x52ad XOR 0x5245 = 0x00e8).</li><li>stosw — store the XOR result (AX = 0xe8) at the memory address from EDI register (rwx_mem).</li><li>Jump to “dcd” label and repeat the whole process 89 times (ECX), decreasing ECX every next loop iteration.</li><li>After the whole process finished we can jump to the address where “rwx_mem” is pointing to. It’s going to be an actual code that parses.</li></ol><h3>Decoding HEX bytes</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1007/0*_iFGcYzxaMUUxj57.gif" /><figcaption>Olly Debugger — analyzing assembly snippet</figcaption></figure><p>After all bytes were decoded and copied we can find an actual string that says we need to put a password there. Mentioned string is marked by a red square on a picture bellow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/0*DC9IYgT6lhpLxKpw.png" /><figcaption>Inspecting memory — password visible in the data dump</figcaption></figure><p>You should notice the sentence which wasn’t visible before, TutajWpiszTajneHaslo!!!. It&#39;s a Polish sentence which translates into English as PutYourSecretPasswordHere!!!. I&#39;m going to refer to this as a <strong>hidden message</strong>.</p><p>Bellow is the code where we jumped to from the instruction jmp rwx_mem:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/0*tSInqeewOBBkinjG.png" /><figcaption>Assembly code</figcaption></figure><p>Mentioned code is pretty straightforward and what it does is a simple iteration over our hidden message to generate the CRC32 checksum. We need to be aware of that the assembly instruction CRC32C is actually not a standard CRC32 function which is commonly used. There is a special instruction set called SSE4 which introduced this function in the Intel processors - <a href="https://en.wikipedia.org/wiki/SSE4">SSE4 - Wikipedia</a>. It&#39;s <strong>CRC32C</strong> which does return a different result than a standard function.</p><p>Within this loop which repeats exactly 23 times (the string length of TutajWpiszTajneHaslo!!!) we calculate CRC32C checksum:</p><ul><li><strong>1st</strong> iteration: CRC32C is calculated using TutajWpiszTajneHaslo!!!.</li><li><strong>2nd</strong> iteration: CRC32C is calculated using utajWpiszTajneHaslo!!!.</li><li><strong>3rd</strong> iteration: CRC32C is calculated using tajWpiszTajneHaslo!!!.</li></ul><p>Every next iteration CRC32C checksum calculation starts at the <strong>n-th</strong> letter. At the end this code will calculate a checksum <strong>only from the laster letter</strong> — that’s an important information.</p><p>Instruction cmp dword ptr [ebp+ecx*4+61], eax is checking if generated CRC32C value is the same as one stored at the address ebp+ecx*4+61 (it&#39;s an array of checksums). If it does match then we start another loop iteration, if not then code &quot;stops&quot;.</p><p>The obvious thing is that I didn’t have any checksum that was matching those checksums referenced within an array, even after the first loop iteration my generated CRC32C was invalid. At first I thought maybe this XOR decoding routine broke something and that’s the reason checksum doesn’t match…</p><p>There is an array that stores 23 different CRC32C checksums that are compared to those generated from TutajWpiszTajneHaslo!!!. After some checks I realised that code is actually valid and XOR decoding procedure also works fine.</p><h3>Magic checksums</h3><p>If you modify mentioned hidden message your CRC32C checksum will change. Here comes a tricky part, if we have an array with 23 valid checksums we need to generate a <strong>new</strong> hidden message that will match exactly those values.</p><p>Not only the checksum of the whole hidden message needs to be valid but also every its character. It means that finding the collision in CRC32C will not resolve our issue, we need to <strong>brute force</strong> that. We know exactly what is a value of CRC32C checksum in every step of our loop.</p><p><strong>Pseudocode for mentioned brute-force script:</strong></p><p>We iterate from the last character to the first one, in a reverse order.</p><ol><li>Dump a list of all valid checksums (array) from the memory.</li><li>Iterate from the last CRC32C value in that array.</li><li>Generate checksum for every character in a range 0–255.</li><li>If generated checksum does match then move to the next valid checksum and repeat that process.</li><li>At the end we’re going to receive a valid string that matches to all checksums.</li></ol><p>I dumped the memory after XOR operation directly from EDB to a file named decoded.dump.bin.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/855b8af23f816f50119d70bb319df03b/href">https://medium.com/media/855b8af23f816f50119d70bb319df03b/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/38538efc6dae056f7e1a38ce57bbf641/href">https://medium.com/media/38538efc6dae056f7e1a38ce57bbf641/href</a></iframe><h3>Brute-force</h3><p>We have everything we need to know, how to find valid checksums and write brute-force code. I struggled here for a while because every software implementation of CRC32C I did find wasn’t generating a valid result. I tried C, Python and Node.JS libraries, without a success. That was the main reason why I decided to write this brute-force script in a pure assembly. I can use there built-in hardware support for CRC32C instruction without a need to actually use any external libraries.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/28ac2e6a2ad26e293e9992bb7a08830b/href">https://medium.com/media/28ac2e6a2ad26e293e9992bb7a08830b/href</a></iframe><p>As a result it prints out a new valid hidden message:</p><p><strong>Our flag is:</strong> coldwind.pl/piwflag1337</p><p>This is an actual URL address <a href="http://coldwind.pl/piwflag1337">http://coldwind.pl/piwflag1337</a> where details for winners were described.</p><p><em>Originally published at </em><a href="https://vulnsec.com/2017/reverse-engineering-a-book-cover/"><em>https://vulnsec.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=44c2f841d0c1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Firefox and Burp Suite]]></title>
            <link>https://medium.com/@radekk/firefox-and-burp-suite-the-most-secure-configuration-3c08e6c23194?source=rss-b6186669a1c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c08e6c23194</guid>
            <category><![CDATA[bug-bounty]]></category>
            <category><![CDATA[bugs]]></category>
            <category><![CDATA[burpsuite]]></category>
            <category><![CDATA[firefox]]></category>
            <category><![CDATA[pentesting]]></category>
            <dc:creator><![CDATA[@radekk]]></dc:creator>
            <pubDate>Thu, 05 Sep 2019 07:01:02 GMT</pubDate>
            <atom:updated>2019-09-13T07:31:16.169Z</atom:updated>
            <content:encoded><![CDATA[<h3>Firefox and Burp Suite — the most secure configuration</h3><p>There is a few popular ways to run <a href="https://portswigger.net/burp">Burp Suite</a> from PortSwigger in the pentesting environment. The simplified approach is to have a dedicated web browser to use (only) with Burp.</p><p>The downside is that the proxy setting for the browser (Chrome and Safari) needs to be set on the system level — on the Mac OS X. As a result, the <strong>whole</strong> HTTP and HTTPS traffic from the system would be routed through Burp and not only traffic from the browser but also traffic from the installed applications.</p><p>Proxy configuration in Firefox is set directly <strong>in the browser</strong>. There is no need to modify system settings.</p><h3>Multiple Firefox profiles</h3><p>Firefox allows creating separate profiles acting as containers storing sensitive information separated from each other. Each profile stores its own:</p><ul><li>Cookies</li><li>Extensions</li><li>Security certificate settings</li><li>and more…</li></ul><blockquote>&quot;Security certificate settings: The cert9.db file stores all your security certificate settings and any SSL certificates you have imported into Firefox.&quot;</blockquote><p>Burp requires cacert.der (CA cert) to be imported in the browser or system keychain (not recommended) to intercept HTTPS traffic. If attacker would get this certificate and <a href="https://en.wikipedia.org/wiki/Man-in-the-middle_attack">MITM</a> your connection (i.e., when using public Wi-Fi) he would get your whole traffic, unencrypted.</p><p>That is why storing this certificate in your browser, is not a good idea, because it opens up a new attack vector. If you are curious about what might happen, read about a similar case from Dell: <a href="https://www.zdnet.com/article/dell-in-hot-water-again-as-second-superfish-root-certificate-surfaces/">eDellroot issue</a></p><p><em>On every new installation or when Burp’s configuration is wiped out, it would generate a new CA certificate served from “http://burp/cert&quot; URL. It significantly makes the attack harder from the malicious actor perspective.</em></p><p>Thanks to Firefox and its multiple profiles, we can install cacert.der <strong>only in a separate profile</strong> and keep the default one without Burp&#39;s CA certificate. That allows running two Firefox instances, side by side with each other. Furthermore, you can install all of the necessary plugins in Burp&#39;s Firefox profile, and it will not affect the default one.</p><p>Read more on <a href="https://support.mozilla.org/en-US/kb/profiles-where-firefox-stores-user-data">Firefox profiles</a>.</p><h3>Configuration</h3><ol><li>Open Firefox and go to about:profiles URL</li><li>Create a new profile and name it “Burp”</li><li>Click on the “Launch profile in new browser” button</li><li>New Firefox window should Open</li><li>Install Foxy Proxy extension if needed</li><li>Change Firefox theme to easily distinguish between “default” and “Burp” profiles</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*TgDQZkO19CpqdYiv.png" /><figcaption>List of created profiles in Firefox browser</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nOyvjCbgEBx706ZA.png" /><figcaption>Proxying traffic from a new Firefox profile through Burp Suite — using FoxyProxy extension</figcaption></figure><p>Whenever you want to run “Burp” profile open Firefox and go to “about:profiles” to launch it, there is an option to use <a href="https://spf13.com/post/managing-multiple-firefox-profiles-in-os-x/">CLI to run a profile</a> as well.</p><pre>/Applications/Firefox.app/Contents/MacOS/firefox-bin --profilemanager</pre><h3>Takeaways</h3><ul><li>Do not install cacert.der in your (default) web browser, especially do not install that directly into the system keychain</li><li>Always separate your pentesting tools and activities from your day-to-day environment/configuration</li><li>If possible, run Burp inside virtual machine or on the remote instance to avoid embarrassing incidents if someone hacks you through the Burp Suite installation. Software is software, and vulnerabilities do happen</li></ul><p><em>Originally published at </em><a href="https://vulnsec.com/2019/firefox-burp-suite-configuration/"><em>https://vulnsec.com</em></a><em>.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c08e6c23194" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Detecting secrets in source code]]></title>
            <link>https://medium.com/auth0-engineering/detecting-secrets-in-source-code-bd63b0fe4921?source=rss-b6186669a1c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/bd63b0fe4921</guid>
            <category><![CDATA[security]]></category>
            <category><![CDATA[tools]]></category>
            <category><![CDATA[serverless]]></category>
            <dc:creator><![CDATA[@radekk]]></dc:creator>
            <pubDate>Mon, 12 Jun 2017 15:20:55 GMT</pubDate>
            <atom:updated>2017-06-12T16:50:22.588Z</atom:updated>
            <content:encoded><![CDATA[<p><em>We’re open-sourcing a new security tool called </em><a href="https://github.com/auth0/repo-supervisor"><strong><em>Repo Supervisor</em></strong></a><strong><em>.</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s8XUj5leOV9_1rhuB-6zGQ.png" /><figcaption>The main view on the HTML report.</figcaption></figure><h3>Problem we wanted to solve</h3><p>A while ago, we released a tool that <a href="https://github.com/radekk/mfa-monitor">monitors the status of the Multi-Factor authentication</a> (MFA) setting for Amazon Web Services (AWS) and Github by sending Slack alerts: <a href="https://auth0.com/blog/the-mfa-monitoring-tool/">https://auth0.com/blog/the-mfa-monitoring-tool/</a>. It works as a serverless application on our <a href="https://auth0.com/extend/">Auth0 Extend</a> platform.</p><p>On the security team, we try to solve different problems by automating a variety of tasks. The reason behind creating a tool to look for secrets in our source code was SDLC. Our primary focus at the moment is to replace as much of the human factor in the process of secure software development as we can. Our aim was to detect possible secrets committed to the source code by accident, especially for big pull requests, where you may miss a single line with a hard-coded secret or a password.</p><p>If you want to read more about our approach to cloud security which is not strictly related to this blog post, you can read our previous articles.</p><ul><li><a href="https://auth0.engineering/cloud-security-monitoring-at-auth0-ff5e87ad1141">Cloud Security Monitoring at Auth0</a></li><li><a href="https://auth0.engineering/cloud-security-monitoring-at-auth0-part-ii-b106354a0e5d">Cloud Security Monitoring at Auth0 — Part II</a></li></ul><h3>Choosing the appropriate tool for that job</h3><p>Before we started writing a single line of code we evaluated tools available on the market. There are a couple of interesting implementations that can detect secrets in the source code like <em>truffleHog</em> or <em>git-secrets,</em> but they lacked important features we wanted, pushing us in the direction of writing our own implementation.</p><p><strong>Features missing from available tools:</strong></p><ul><li>Webhook mode to scan all incoming pull requests.</li><li>Ability to scan data specifically for a file format like strings for javascript files (*.js) or object properties and values from JSON files (*.json).</li><li>Serverless compatibility to run it without actually putting effort into spinning up instances.</li><li>Slack alerts to notify us about newly detected secrets.</li><li>Nice and slick HTML reports we can link to.</li><li>Ability to decrease the number of false positives. We keep a custom exclude list, which is must-have if you want to get rid of things like email addresses or URLs that generate high entropy results.</li></ul><p>So we put every single feature mentioned above into our custom tool called <strong>Repo Supervisor</strong>. It was created in JavaScript with modern technologies and extensibility in mind. As part of the build process, we generate a single JavaScript file that can be sent to the serverless platform directly, whether it is Webtask (Auth0 Extend) or AWS Lambda.</p><h3>Webhook mode</h3><p>Before using our tool in a webhook mode, you need to build it to generate a single JavaScript file and then deploy that on the serverless platform i.e. Auth0 Extend. Then, when you have a single URL pointing to an instance of Repo Supervisor, just add a new webhook to the repository on Github. Read the documentation for details —<a href="https://github.com/auth0/repo-supervisor#webhook"> https://github.com/auth0/repo-supervisor#webhook</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zr-GLKbvAeqCUNfkLbk6jw.png" /><figcaption>Setting up a new webhook on Github.</figcaption></figure><h3>Custom file formats</h3><p>We can extract strings from specific file formats. In short, it means that if there is going to be a custom file format in the pull request submission you can write a wrapper for that so Repo Supervisor can detect secrets. It may be a parser for binary files, an sqlite database and much more. It’s fully extensible.</p><p><a href="https://github.com/auth0/repo-supervisor/wiki/Custom-file-formats">https://github.com/auth0/repo-supervisor/wiki/Custom-file-formats</a></p><h3>Serverless</h3><p>Allowing this script to run without building up the whole infrastructure was crucial here. At Auth0, we used to create a lot of tools based on our custom serverless solution (Auth0 Extend) and so far, it works pretty well. We do support internal databases up to 1MB, encrypted secrets storage, crontab jobs and more.</p><p><a href="http://auth0.com/extend">Auth0 Extend</a></p><p>You can host this tool on AWS Lambda, and everything depends on the current stack you have deployed in your environment. It should work with any FaaS platform; deploy once and forget about maintaining it.</p><h3>Slack alerts</h3><p>Almost instantly, when there are secrets detected in pull requests, we receive Slack notifications. Whether the user decided that report is accurate (not false positives detected) or not, he can choose the appropriate button which generates an additional Slack message. We added this feedback part because of false positives we wanted to get rid off. So, with that solution in mind, developers can help to improve our tool and make reports more relevant.</p><p>Slack integration is using <a href="https://api.slack.com/incoming-webhooks"><em>Incoming Webhooks</em></a><em>,</em> and its configuration takes 20 seconds. You just need to create a new incoming webhook integration, choose the channel name where you want to receive new alerts and copy the generated URL into Repo Supervisor’s config file “.<em>config.json”</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NYVLzqEA-A5BR84pCPzUog.png" /><figcaption>Messages on the Slack channel where Repo Supervisor sends notifications.</figcaption></figure><h3>HTML reports</h3><p>One advantage to having the right tools is generating reports that you can share with people. Every time a new task is created in Asana, Github, Jira or whatever tool you use for tracking issues, you can link directly to the report that was generated for a particular pull request.</p><p>The HTML report consists of a list of all files in which secrets were detected, and it’s grouped by file path. Every single group contains all (obfuscated) secrets together with entropy level on the right. By clicking on a file path header, you’re going to be directly redirected to the file on Github.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/709/1*GjGmPRUoKtEg7ee-4mQAYQ.png" /><figcaption>HTML report generated by Repo Supervisor tool.</figcaption></figure><h3>False positives</h3><p>It’s hard for a single script to distinguish whether a string detected as a secret is a real secret. When we checked different strings and measured their entropy levels, it occurred that there is a lot of false positives generated by:</p><ul><li>E-mail addresses</li><li>URL addresses</li><li>Object keys i.e. <em>“SECRET_KEY_FOR_AWS”</em></li><li>File paths i.e. <em>“/etc/init.d/script.sh”</em> or <em>”./../../../config.js”</em></li><li>CSS selectors i.e. ‘<em>button[value=“test”]’</em> or <em>“#super-random-name”</em></li></ul><p>If the tool is too noisy and generates a lot of alerts, people tend to ignore them. It was crucial for us to both get rid off false positives and decrease the number of real secrets being ignored. It’s a tradeoff we agreed to.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/da1ec79d25d9c2bfcf7c9e2c3a68ef70/href">https://medium.com/media/da1ec79d25d9c2bfcf7c9e2c3a68ef70/href</a></iframe><h3>Measuring the level of entropy</h3><p>One of the modules that Repo Supervisor implements is the entropy meter, which measures the level of entropy for every single string that parsers returned. Depending on the level, we set a red flag on the string as a potential secret or skip it and scan further.</p><p>In the default configuration, <em>“maxAllowedEntropy”</em> was set to 4 which means that all strings with entropy higher than 4.0 are going to be marked as potential secrets. The module implemented in JavaScript that calculates the entropy level goes as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/96a5fa9f2f4427455e7c03aeb61d131e/href">https://medium.com/media/96a5fa9f2f4427455e7c03aeb61d131e/href</a></iframe><p>We don’t measure entropy on 100% of characters in a file. How much and what is measured depends on the format we’re parsing. For both <strong>JSON</strong> and <strong>JavaScript</strong> files, we extract all strings and iterate over these values to measure entropy level. It allows us to skip all the noisy things, like function names, or variable names which could generate high entropy and lead to a false positive.</p><h3>Supported modes</h3><p>Repo Supervisor works in <strong>CLI</strong> and <strong>Serverless </strong>modes. It allows the scanning of files locally without needing to install a webhook on Github or deploy it to Auth0 Extend or AWS Lambda.</p><p><strong>In the command-line mode</strong>, a tool is recursively scanning the whole directory provided as a parameter. It looks for files with supported extensions (configured in “config/main.json” file) and skips file formats that aren’t supported. Then all enabled filters, like the entropy meter, are applied. As a result, a tool prints out detected secrets grouped by file paths.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9qsJhNmHCg5f0aycJpOMVg.png" /><figcaption>Command-line (CLI) mode diagram.</figcaption></figure><p><strong>The serverless mode</strong> consists of a lot more steps than CLI mode. It requires the deployed Repo Supervisor and installed webhook for a repository. Every new created or updated pull request triggers a webhook, and a scan for secrets starts.</p><p>As a result, we set the continuous integration (CI) status on pull request with a link to the report. To pass parameters to Repo Supervisor in the URL in a safe way, we use <strong>JWT</strong> (JSON Web Tokens) because it allows us to sign parameters, add a custom value like pull request ID and trust the payload itself. In that way, we don’t need to store any values in the external databases/services, and we keep it purely serverless.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B1pN7L9RKXjbXP4yuwznsg.png" /><figcaption>Serverless mode diagram.</figcaption></figure><h3>What’s next?</h3><p>We encourage you to test out the Repo Supervisor and send bugs and improvements to help us make it better.</p><p>Detecting secrets is just part of the bigger picture, and you need to have the migration path for these secrets implemented, too.</p><p>There needs to be a procedure after secrets are detected. Without that, it may be pointless. Some secrets may be in the source code by accident, so you can just get rid of them, but what about real secrets that developers need to have in their applications?</p><p>Create a procedure for secrets migration, and give developers the appropriate tools to do their jobs. As a part of our effort at Auth0, we are implementing support for <a href="https://aws.amazon.com/kms/">KMS</a> and <a href="https://github.com/fugue/credstash">Credstash</a> to avoid secrets flying around. Give it a try, and stay secure.</p><p><a href="https://github.com/auth0/repo-supervisor">GitHub - auth0/repo-supervisor: Scan your code for security misconfiguration, search for passwords and secrets. :mag:</a></p><p><strong>Happy secrets hunting!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd63b0fe4921" width="1" height="1" alt=""><hr><p><a href="https://medium.com/auth0-engineering/detecting-secrets-in-source-code-bd63b0fe4921">Detecting secrets in source code</a> was originally published in <a href="https://medium.com/auth0-engineering">Auth0 Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>