You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tait.tech/_site/2020-04-27-quiz-your-friend...

1 line
6.0 KiB

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>The "Quiz Your Friends" XSS Exploit | tait.tech</title> <link rel="stylesheet" href="/assets/css/style.css"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <div id="wrapper"> <nav> <input type="checkbox" id="menu"> <label for="menu">&#9776;</label> <div class="menu-content"> <a href="/" class="nav-link">Home</a> <a href="/blog/" class="nav-link">Blog</a> <a href="/links/" class="nav-link">Links</a> <a href="https://github.com/TTWNO/" class="nav-link" target="_blank" rel="noopener noreferrer">Code</a> </div> </nav> <main> <header> <h1>The "Quiz Your Friends" XSS Exploit</h1> <span class="post-date"></span> </header> <hr> <div class="article"> <h2 id="todo-write-intro">TODO write intro</h2> <h2 id="how-i-found-this-exploit">How I Found This Exploit</h2> <p>While filling in one of my friends surveys I thought it would be funny for them to know it is me without anyone else knowing. We were young and had <code class="language-plaintext highlighter-rouge">Inspect Element</code>ed a few things together, so it was a safe bet that an HTML joke would let them know.</p> <p>I decided to write my name like so: <code class="language-plaintext highlighter-rouge">&lt;b&gt;Steve&lt;/b&gt;</code>. Steve is in reference to the <a href="https://minecraft.gamepedia.com/Player">main character</a> in the video game Minecraft.</p> <figure> <img src="/assets/img/qyf-xss/2-bold.png"/> <figcaption> <p>Me typing in my name as <span class="mono">&lt;b&gt;Steve&lt;/b&gt;</span>.</p> </figcaption> </figure> <p>Now in theory this should have shown in in the leaderboard as: “&lt;b&gt;Steve&lt;/b&gt;” However, to my horror and excitement, I saw this in the leaderboard:</p> <figure> <img src="/assets/img/qyf-xss/3-steve-board.png"/> <figcaption> <p><span class="mono">&lt;b&gt;Steve&lt;/b&gt;</span> displaying in the leaderboard as bold text: <b>Steve</b></p> </figcaption> </figure> <p>The text “Steve” showed up <strong>in bold</strong> on the leaderboard. This told me all I needed to know. How did this happen? You might wonder.</p> <h3 id="server-side-validation">Server-Side Validation</h3> <p>Here is a great demonstration why you should do most of your validation on the server side. As a user, I can edit any of the HTML, CSS, or Javascript your server serves to me.</p> <p>Quiz your friends uses the <code class="language-plaintext highlighter-rouge">maxlength=20</code> HTML attribute on the name input field. Imagine trying to fit in a script tag doing anything useful with 20 characters! Dont forget that includes the <code class="language-plaintext highlighter-rouge">&lt;script&gt;</code> tag. That would leave 13 characters for Javascript. Although Im sure a genius would be able to <a href="https://code.golf/">code golf</a> that, I know I couldnt.</p> <p>Now obviously I can edit any HTML that a server has sent to me. If I open up my inspect element window, I can go ahead and change that <code class="language-plaintext highlighter-rouge">maxlength</code> attribute to anything I want. Lets change it to 100!</p> <figure> <img src="/assets/img/qyf-xss/5-maxlength.png" alt="An image of the Quiz Your Friends name input field with inspect element. THe code reads: &lt;font class=&quot;style6&quot;&gt;&lt;input class=&quot;inputbutton&quot; name=&quot;takername&quot; type=&quot;text&quot; id=&quot;takername&quot; maxlength=&quot;20&quot; width=&quot;425&quot; placeholder=&quot;Your First Name&quot; style=&quot;text-align: center; text-decoration:inherit; font-size:38px;&quot; tabindex=&quot;-1&quot;&gt;&lt;/font&gt;"/> <figcaption> Manually changing the maxlength attribute. </figcaption> </figure> <p>In theory, there is a way that a site can stop people from just putting in their name of any length: server-side validation. The server <em>could</em> check to see if the input is too long and reject it if it is. The Quiz My Friends server has <em>no such checks in place</em>. Therefore, I can send an almost arbitrary load to them. Being