","Gruyere, just like many sites with ","custom error pages",", is designed to include the path component in the HTML page. This can introduce security bugs, like XSS, as it introduces user input directly into the rendered HTML page of the web application. You might say, “It’s just an alert box, so what?” The thing is, if I can inject an alert box, I can most likely inject something else, too, and maybe steal your cookies which I could use to sign in to your site as you.","Another example is when the stored user input isn’t sanitized. Let’s say I write a comment on your blog; the comment is simple:","Click here to see a kitten","If other users click on my innocent link, I have their cookies:","You can learn how to find XSS vulnerabilities in your own web app and how to fix them in the second part of ","; or, if you’re an advanced developer, take a look at the automatic escaping features in template systems we blogged about previously on ","this blog",".","Cross-site request forgery (XSRF) - Should I trust requests from evil.com?"," Oops, a broken picture. It can’t be dangerous--it’s broken, after all--which means that the URL of the image returns a 404 or it’s just malformed. Is that true in all of the cases?","No, it’s not! You can specify any URL as an image source, regardless of its content type. It can be an HTML page, a JavaScript file, or some other potentially malicious resource. In this case the image source was a simple page’s URL:","That page will only work if I’m logged in and I have some cookies set. Since I was actually logged in to the application, when the browser tried to fetch the image by accessing the image source URL, it also deleted my first snippet. This doesn’t sound particularly dangerous, but if I’m a bit familiar with the app, I could also invoke a URL which deletes a user’s profile or lets admins grant permissions for other users.","To protect your app against XSRF you should not allow state changing actions to be called via GET; the POST method was invented for this kind of state-changing request. This change alone may have mitigated the above attack, but usually it's not enough and you need to include an unpredictable value in all state changing requests to prevent XSRF. Please head to "," if you want to learn more about XSRF.","Cross-site script inclusion (XSSI) - All your script are belong to us","Many sites today can dynamically update a page's content via asynchronous JavaScript requests that return JSON data. Sometimes, JSON can contain sensitive data, and if the correct precautions are not in place, it may be possible for an attacker to steal this sensitive information.","Let’s imagine the following scenario: I have created a standard HTML page and send you the link; since you trust me, you visit the link I sent you. The page contains only a few lines:","","Since you’re signed in to Gruyere and you have a private snippet, you’ll see an alert box on my page informing you about the contents of your snippet. As always, if I managed to fire up an alert box, I can do whatever else I want; in this case it was a simple snippet, but it could have been your biggest secret, too.","It’s not too hard to defend your app against XSSI, but it still requires careful thinking. You can use tokens as explained in the XSRF section, set your script to answer only POST requests, or simply start the JSON response with ‘\\n’ to make sure the script is not executable.","SQL Injection - Still think user input is safe?","What will happen if I try to sign in to your app with a username like","JohnDoe’; DROP TABLE members;--","While this specific example won’t expose user data, it can cause great headaches because it has the potential to completely remove the SQL table where your app stores information about members.","Generally, you can protect your app from SQL injection with proactive thinking and input validation. First, are you sure the SQL user needs to have permission to execute “DROP TABLE members”? Wouldn’t it be enough to grant only SELECT rights? By setting the SQL user’s permissions carefully, you can avoid painful experiences and lots of troubles. You might also want to configure error reporting in such way that the database and its tables’ names aren’t exposed in the case of a failed query.","Second, as we learned in the XSS case, never trust user input: what looks like a login form to you, looks like a potential doorway to an attacker. Always sanitize and quotesafe the input that will be stored in a database, and whenever possible make use of statements generally referred to as prepared or parametrized statements available in most database programming interfaces.","Knowing how web applications can be exploited is the first step in understanding how to defend them. In light of this, we encourage you to take the ","Gruyere course",", take other web security courses from the ","Google Code University"," and check out ","skipfish"," if you're looking for an automated web application security testing tool. If you have more questions please post them in our ","Webmaster Help Forum","\n\n\n \n \n\n\n\n\n \n \n\n\n\n\n\n \n \n\n\n","\nLabels\n","\n \n ","\n#sharethemicincyber\n","\n#supplychain #security #opensource\n","\nandroid\n","\nandroid security\n","\nandroid tr\n","\napp security\n","\nbig data\n","\nbiometrics\n","\nblackhat\n","\nC++\n","\nchrome\n","\nchrome enterprise\n","\nchrome security\n","\nconnected devices\n","\nCTF\n","\ndiversity\n","\nencryption\n","\nfederated learning\n","\nfuzzing\n","\nGboard\n","\ngoogle play\n","\ngoogle play protect\n","\nhacking\n","\ninteroperability\n","\niot security\n","\nkubernetes\n","\nlinux kernel\n","\nmemory safety\n","\nOpen Source\n","\npha family highlights\n","\npixel\n","\nprivacy\n","\nprivate compute core\n","\nRowhammer\n","\nrust\n","\nSecurity\n","\nsecurity rewards program\n","\nsigstore\n","\nspyware\n","\nsupply chain\n","\ntargeted spyware\n","\ntensor\n","\nTitan M2\n","\nVDP\n","\nvulnerabilities\n","\nworkshop\n","\n \n ","\nArchive\n","\n\n\n \n \n\n\n\n\n \n \n  \n \n\n\n\n2024\n\n","\nJul\n","\nJun\n","\nMay\n","\nApr\n","\nMar\n","\nFeb\n","\nJan\n","\n\n\n \n \n\n\n\n\n \n \n  \n \n\n\n\n2023\n\n","\nDec\n","\nNov\n","\nOct\n","\nSep\n","\nAug\n","\n\n\n \n \n\n\n\n\n \n \n  \n \n\n\n\n2022\n\n","\n\n\n \n \n\n\n\n\n \n \n  \n \n\n\n\n2021\n\n","\n\n\n \n \n\n\n\n\n \n \n  \n \n\n\n\n2020\n\n","\n\n\n \n \n\n\n\n\n \n \n  \n \n\n\n\n2019\n\n","\n\n\n \n \n\n\n\n\n \n \n  \n \n\n\n\n2018\n\n","\n\n\n \n \n\n\n\n\n \n \n  \n \n\n\n\n2017\n\n","\n\n\n \n \n\n\n\n\n \n \n  \n \n\n\n\n2016\n\n","\n\n\n \n \n\n\n\n\n \n \n  \n \n\n\n\n2015\n\n","\n\n\n \n \n\n\n\n\n \n \n  \n \n\n\n\n2014\n\n","\n\n\n \n \n\n\n\n\n \n \n  \n \n\n\n\n2013\n\n","\n\n\n \n \n\n\n\n\n \n \n  \n \n\n\n\n2012\n\n","\n\n\n \n \n\n\n\n\n \n \n  \n \n\n\n\n2011\n\n","\n\n\n \n \n\n\n\n\n \n \n  \n \n\n\n\n2010\n\n","\n\n\n \n \n\n\n\n\n \n \n  \n \n\n\n\n2009\n\n","\n\n\n \n \n\n\n\n\n \n \n  \n \n\n\n\n2008\n\n","\n\n\n \n \n\n\n\n\n \n \n  \n \n\n\n\n2007\n\n","Feed","Follow @google","Follow","\nGive us feedback in our Product Forums.\n","\n Google\n ","\n Privacy\n ","\n Terms\n "]}