{"id":754,"date":"2019-04-25T19:01:01","date_gmt":"2019-04-25T19:01:01","guid":{"rendered":"http:\/\/www.smart-bricks.net\/?p=754"},"modified":"2019-04-28T22:23:12","modified_gmt":"2019-04-28T22:23:12","slug":"the-5-most-critical-web-application-security-risks","status":"publish","type":"post","link":"http:\/\/www.smart-bricks.net\/index.php\/2019\/04\/25\/the-5-most-critical-web-application-security-risks\/","title":{"rendered":"The 5 most critical web application security risks"},"content":{"rendered":"\n<p><em>OWASP provides a comprehensive list of<strong> the most common vulnerabilities<\/strong>, and here, we will show you 5 of them which you have to <strong>take into account during the entire dev process<\/strong>.<\/em><\/p>\n\n\n\n<p>Developing a real work web application can be really challenging. <strong>The developer team must have very good skills in all the layers from the frontend down to the very backend<\/strong>. This challenge is even bigger when considering the most common security risks that web applications can have.<\/p>\n\n\n\n<p>The Open Web Application Security Project&nbsp;(OWASP) wrote a document \nwith a list of the top 10 most critical web application security risks \nwith the goal to make companies aware of such important and common \nissues so that they can take proper action to avoid them. Here, and for \nthe sake of brevity, I am going to describe<strong> the 5 most critical security risks<\/strong> in the list.<\/p>\n\n\n\n<h2>1. SQL injection<\/h2>\n\n\n\n<p>Consider an application that takes a text as input from a user in order to build a query (command).<\/p>\n\n\n\n<p>If this query is built concatenating the user input without escaping special characters,<strong> the attacker can trick the interpreter by inserting special commands<\/strong>.<\/p>\n\n\n\n<p>The most common example is the <strong>SQL Injection vulnerability<\/strong>. To be more illustrative, imagine that we have a query like this inside the application:\n\n\n\n\t\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\t&#8220;SELECT name FROM users\n\n WHERE name = &#8216;&#8221; + name + &#8220;&#8216; AND password = &#8216;&#8221; + password + &#8220;&#8216;&#8221;\n\t\t\t\n\t\t\t\t<\/p>\n\n\n\n<table class=\"wp-block-table\"><tbody><tr><td>\n\t\t\t\t\t123\n\t\t\t\t<\/td><td>&#8220;SELECT name FROM users&nbsp; WHERE name = &#8216;&#8221; + name + &#8220;&#8216; AND password = &#8216;&#8221; + password + &#8220;&#8216;&#8221;<\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>\nImagine that there is a form where the application reads &lt;name&gt; and &lt;password&gt;.<\/p>\n\n\n\n<p>The attacker will be able to exploit this vulnerability easily by writing:\n\n\n\n\t\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\tname = foo\n\npassword =  &#8216; OR &#8216;1&#8217; = 1\n\t\t\t\n\t\t\t\t<\/p>\n\n\n\n<table class=\"wp-block-table\"><tbody><tr><td>\n\t\t\t\t\t123\n\t\t\t\t<\/td><td>name = foo&nbsp;password =&nbsp;&nbsp;&#8216; OR &#8216;1&#8217; = 1<\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>\nThe query will end up with this form:\n\n\n\n\t\t\n\t\t\n\t\t\t\n\t\t\t\n\t\t\tSELECT name FROM users\n\nWHERE name = &#8216;foo&#8217; AND password = &#8221; OR &#8216;1&#8217; = &#8216;1&#8217;\n\t\t\t\n\t\t\t\t<\/p>\n\n\n\n<table class=\"wp-block-table\"><tbody><tr><td>\n\t\t\t\t\t123\n\t\t\t\t<\/td><td>SELECT name FROM users&nbsp;WHERE name = &#8216;foo&#8217; AND password = &#8221; OR &#8216;1&#8217; = &#8216;1&#8217;<\/td><\/tr><\/tbody><\/table>\n\n\n\n<p>\nThe addition of <strong>OR \u20181\u2019 = \u20181\u2019<\/strong> will make the <strong>where<\/strong> clause to always be <strong>true.<\/strong> This means the query will retrieve the complete list of users in the application. You can find more examples <a href=\"https:\/\/www.owasp.org\/index.php\/SQL_Injection\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n\n\n\n<p>In order to not have this issue, you should never concatenate strings to build queries. You should <strong>use Prepared Statements, Criterias, LINQ, or any other mechanism provided by frameworks<\/strong>.<\/p>\n\n\n\n<h2>2. Sensitive data exposure<\/h2>\n\n\n\n<p>This exposure is related to<strong> how sensitive data is transmitted and stored<\/strong>. It can occur when:<\/p>\n\n\n\n<ul><li>Sensitive data is transmitted in clear text from browsers to servers and vice versa (external traffic).<\/li><li>Sensitive data is transmitted in clear text between servers (internal traffic).<\/li><li>Sensitive data is stored in clear text.<\/li><li>A weak or old cryptographic algorithm is used.<\/li><\/ul>\n\n\n\n<p>To prevent this vulnerability:<\/p>\n\n\n\n<ul><li>Do not unnecessarily store sensitive data, and discard it as soon as possible.<\/li><li>Make sure you encrypt all sensitive data that must be stored.<\/li><li>Encrypt all data in transit, such as using https.<\/li><li>Ensure that up-to-date and strong standard algorithms or ciphers are used.<\/li><li>Disable caching for responses that contain sensitive data.<\/li><\/ul>\n\n\n\n<h2>3. Broken authentication and session management<\/h2>\n\n\n\n<p><strong>Authentication and session management in web applications are often not implemented correctly<\/strong>,\n allowing attackers to compromise passwords, keys, session tokens, or to\n exploit other implementation flaws to assume other users\u2019 identities.<\/p>\n\n\n\n<p>Some examples are:<\/p>\n\n\n\n<ul><li><strong>Passwords are not stored with a hashingor an encryption protection<\/strong>. If the attacker accesses the store, he will be able to get them easily.<\/li><li><strong>Session IDs exposed in the URL<\/strong>. If an attacker can \nget one URL with such an ID, he will be able to enter into the \napplication as if he were the original user that created the session. \nAnybody can share the link without noticing that he is giving full \naccess to his account in the application.<\/li><li><strong>Session IDs without expiration time and\/or logout function that do not invalidate the session<\/strong>.\n In this case, if the user closes the browser, then another user, \nsometime later, can start the browser again with the same session of the\n previous user.<\/li><\/ul>\n\n\n\n<p><strong>In order to avoid this vulnerability:<\/strong><\/p>\n\n\n\n<ul><li>Use Session ID in headers (not in the URL!).<\/li><li>Sessions must have an expiration time.<\/li><\/ul>\n\n\n\n<h2>4. Cross-Site Scripting (XSS)<\/h2>\n\n\n\n<p>This vulnerability is similar to SQL Injection, in the way that the \nattacker can inject special code, but instead of getting data from \ndatabases (server side), <strong>the attack is done in the browser itself, making it redirect users to websites where attackers can steal data<\/strong>.<\/p>\n\n\n\n<p>This attack is often done<strong> when writing JavaScript code into input text fields of web applications<\/strong>. That code can redirect to the attacker\u00b4s webpage sending cookies, session storage information, and other sensitive data.<\/p>\n\n\n\n<p>In order to avoid this vulnerability, you should <strong>use a GUI framework that has a way to escape\/sanitize the user inputs<\/strong>. For example, use the $sce service in AngularJS.<\/p>\n\n\n\n<h2>5.&nbsp;Broken access control<\/h2>\n\n\n\n<p>This security risk is present in applications that do not properly verify roles and permissions. In other words, <strong>an attacker is able to access a web application resource by just knowing the URL<\/strong>.<\/p>\n\n\n\n<p>In general, the web apps manage roles and permissions just in the frontend, but the backend calls are not validated, so <strong>the attacker can access sensitive data by just accessing directly to the backend<\/strong>.<\/p>\n\n\n\n<p>To avoid this, you should:<\/p>\n\n\n\n<ul><li><strong>Run integration tests<\/strong> to check that the user is redirected to the login page when trying to access to the given page without authentication.<\/li><li><strong>Run tests for every Endpoint<\/strong> to check that it returns the correct error message if no or invalid credentials are provided.<\/li><\/ul>\n\n\n\n<h3>To Sum Up<\/h3>\n\n\n\n<p>OWASP provides a comprehensive list of the most common vulnerabilities. Every developer should <strong>have them in mind in order to avoid them from the very beginning<\/strong>.<\/p>\n\n\n\n<p>It is highly recommended to read the <a href=\"https:\/\/www.owasp.org\/images\/b\/b0\/OWASP_Top_10_2017_RC2_Final.pdf\" target=\"_blank\" rel=\"noreferrer noopener\">whole list<\/a>.\n Besides, you can use open source or paid tools that can run checks \nagainst any website trying to find these vulnerabilities. Last but not \nleast, you should know <strong>how to avoid these problems in the technology stack you are currently working on<\/strong>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>OWASP provides a comprehensive list of the most common vulnerabilities, and here, we will show you 5 of them which you have to take into account during the entire dev process. Developing a real work web application can be really challenging. The developer team must have very good skills in all the layers from the&hellip;&nbsp;<a href=\"http:\/\/www.smart-bricks.net\/index.php\/2019\/04\/25\/the-5-most-critical-web-application-security-risks\/\" class=\"\" rel=\"bookmark\">Read More &raquo;<span class=\"screen-reader-text\">The 5 most critical web application security risks<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[14,18],"_links":{"self":[{"href":"http:\/\/www.smart-bricks.net\/index.php\/wp-json\/wp\/v2\/posts\/754"}],"collection":[{"href":"http:\/\/www.smart-bricks.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.smart-bricks.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.smart-bricks.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.smart-bricks.net\/index.php\/wp-json\/wp\/v2\/comments?post=754"}],"version-history":[{"count":1,"href":"http:\/\/www.smart-bricks.net\/index.php\/wp-json\/wp\/v2\/posts\/754\/revisions"}],"predecessor-version":[{"id":755,"href":"http:\/\/www.smart-bricks.net\/index.php\/wp-json\/wp\/v2\/posts\/754\/revisions\/755"}],"wp:attachment":[{"href":"http:\/\/www.smart-bricks.net\/index.php\/wp-json\/wp\/v2\/media?parent=754"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.smart-bricks.net\/index.php\/wp-json\/wp\/v2\/categories?post=754"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.smart-bricks.net\/index.php\/wp-json\/wp\/v2\/tags?post=754"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}