Presented by Raman But-Husaim
OWASP gives us
someCommand.CommandText = "SELECT AccountNumber FROM Users " +
"WHERE Username='" + name +
"' AND Password='" + password + "'";someCommand.Parameters.Add(
"@username", SqlDbType.NChar).Value = name;
someCommand.Parameters.Add(
"@password", SqlDbType.NChar).Value = password;
someCommand.CommandText = "SELECT AccountNumber FROM Users " +
"WHERE Username=@username AND Password=@password";public enum Something { Cool, Awesome};
Something valueCast = (Something)145;
Something valueParse;
Enum.TryParse("182", out valueParse);
valueCast.Dump(); // 145
valueParse.Dump(); // 182
Good example is our project.
var Shipcity;
ShipCity = Request.form ("ShipCity");
var sql = "select * from OrdersTable where ShipCity = '" + ShipCity + "'";In case of Redmond
SELECT * FROM OrdersTable WHERE ShipCity = 'Redmond'In case of Redmond'; drop table OrdersTable--
SELECT * FROM OrdersTable WHERE ShipCity = 'Redmond';drop table OrdersTable--'See Microsoft Guide
DO: When using SQL Server, prefer integrated authentication over SQL authentication.
We recommend using Windows authentication wherever possible. Windows authentication uses a series of encrypted messages to authenticate users in SQL Server. When SQL Server logins are used, SQL Server login names and encrypted passwords are passed across the network, which makes them less secure.
Proof is here.
Scenarios
@Html.AntiForgeryToken()
[ValidateAntiForgeryToken]
More information and code samples here.
https://securityheaders.com/
Directives
Tips&Tricks
Strict-Transport-Security: max-age=31536000; includeSubDomainsX-XSS-Protection: 1; mode=blockX-XSS-Protection: 0 - disabled xss filtering;
X-XSS-Protection: 1; Default ones however has the following issues.
Proof is here.
Best option:
X-XSS-Protection: 0 - if application is XSS-free or cannot afford an unusual filter/auditor bug;
X-XSS-Protection: 1; mode=block - otherwise
Referrer-Policy: originMore info here.
Recommendations
More info here.
X-Content-Type-Options: nosniffnosniff
blocks a request if the requested type is
X-Frame-Options: denyUseful info here.
Server
Set-Cookie: id=2bf353246gf3; Secure; HttpOnly
Set-Cookie: lang=en; Expires=Wed, 09 Jun 2021 10:18:14 GMT
Client request
Cookie: id=2bf353246gf3; lang=enCookies marked with the ‘Secure’ attribute are only sent over encrypted HTTPS connections and are therefore safe from man in-the-middle attacks.
<httpCookies requireSSL="false" />Useful info here.
Affect all cookies...
Except
<authentication mode="Forms">
<forms loginUrl="~/Something/Wi" timeout="60" requireSSL="true" />
</authentication>Cookies marked with the ‘Secure’ attribute are only sent over encrypted HTTPS connections and are therefore safe from man in-the-middle attacks.
<httpCookies requireSSL="false" />Affect all cookies...
Except
<authentication mode="Forms">
<forms loginUrl="~/Something/Wi" timeout="60" requireSSL="true" />
</authentication>Useful info here.
+ issues with OWIN :)
“Cookies marked with the ‘HttpOnly’ attribute are not accessible from JavaScript and therefore unaffected by cross-site scripting (XSS) attacks.
<httpCookies httpOnlyCookies="true" />Useful info here.
Affect all cookies...
Except
Info could be taken from