loading...
Microsoft Azure

Pushing Left, Like a Boss — Part 5.12 — Authentication (AuthN), Identity and Access Control

shehackspurple profile image Tanya Janca ・4 min read

Pushing Left Like a Boss (23 Part Series)

1) Pushing Left, Like a Boss: Part 1 2) Pushing Left, Like a Boss! -- Part 2: Security Requirements 3 ... 21 3) Pushing Left, Like a Boss! -- Part 3: Secure Design 4) Pushing Left, Like a Boss: Part 4: Secure Coding 5) Pushing Left, Like a Boss — Part 5.1 — Input Validation, Output Encoding and Parameterized Queries 6) Pushing Left, Like a Boss — Part 5.2 — Use Safe Dependencies 7) Pushing Left, Like a Boss — Part 5.3 — Browser and Client-Side Hardening 8) Pushing Left, Like a Boss — Part 5.4 — Session Management 9) Pushing Left, Like a Boss — Part 5.5 — File Uploads 10) Pushing Left, Like a Boss — Part 5.6 — Redirects and Forwards 11) Pushing Left, Like a Boss — Part 5.7 — URL Parameters 12) Pushing Left, Like a Boss — Part 5.8 — Securing Your Cookies 13) Pushing Left, Like a Boss — Part 5.9 — Error Handling and Logging 14) Pushing Left, Like a Boss — Part 5.10 — Untrusted Data 15) Pushing Left, Like a Boss — Part 5.11 — Authorization (AuthZ) 16) Pushing Left, Like a Boss — Part 5.12 — Authentication (AuthN), Identity and Access Control 17) Pushing Left, Like a Boss — Part 5.13 — HTTPS only 18) Pushing Left, Like a Boss, Part 5.14 Secure Coding Summary 19) Pushing Left, Like a Boss - Part 6: Threat Modelling 20) Pushing Left, Like a Boss - Part 7: Code Review and Static Code Analysis 21) Pushing Left, Like a Boss - Part 8: Testing 22) Pushing Left, Like a Boss - Part 9: An AppSec Program 23) Pushing Left, Like a Boss - Part 10: Special AppSec Activities and Situations

**Previously published on my Medium blog, SheHacksPurple.

Note: much of this comes from the OWASP Cheat Sheet on Access Control, by Shruti Kulkarni, Adinath Raveendra Raj, Mennouchi Islam Azeddine and Jim Manico. And if not, it may come from one of the other offerings from the amazing OWASP Cheat Sheets Project. For more information on almost any AppSec topic, check out the project, it’s definitely worth your time!

B-Sides Vancouver, 2019

B-Sides Vancouver, 2019

Let’s start with some definitions.

Authentication is ensuring that the user who is using the application is the actual person they purport to be. For instance, when I log into my webmail, it verifies that I am the one-and-only Tanya Janca that owns this account. Not a different person who is also named “Tanya Janca”, and not someone pretending to be me. The real, authentic, me; the person who owns the account.

Identity (digitally speaking) is a hardware or software-based solution for proof of identity of citizens, users or organizations. For example; in order to access benefits or services provided by government authorities, banks or other companies in person, you must verify your identity, usually with a driver’s license, passport of another physical document. However, if you are verifying your identity digitally (electronically), you must use a software or hardware based solution to prove your identity.

Access Control is allowing (or not) users to access systems, features, data, etc. based on the permissions that the system has assigned to that user. For instance, perhaps you have access to the main parts of your building, but there is an electrical room to which you do not have access. Your badge will not get you it. This is access control, and it works the same way with software, granting or restricting access based on your role and/or identity within the system.

As usual, I recommend using the features as provided in your programming framework (for instance, if you use .NET CORE, use their AuthN, Identity and Access management features to build your software). I also suggest strenuous testing of your implementation, because if someone breaks these security controls there shall be dire consequences.

General Rules of Authentication (AuthN)

  • Applications that use password-based authentication should follow the current NIST Password Standard. Ex: do not forces users to change their passwords often, allow very long passwords, do not force complexity, allow and encourage the use of password managers, etc.

  • The principle of least privilege is the practice of limiting access to the minimal level that will allow normal functioning. This principle should be applied not only to the users of web applications, but to the applications themselves, and as they are given access to databases, web services and other resources. For example, it is rare that an application requires a database user that is the database owner (DBO); generally, read/write is enough.

  • Passwords will be salted and hashed (one-way), not encrypted (two-way), before storing. Use a strong hashing algorithm (again, refer to NIST if you are unsure).

  • Passwords will be encrypted in transit (https only).

  • Re-authentication will be performed for “Sensitive Features”. Sensitive features could include, but are not limited to; changing passwords or security questions, changing bank account information, deleting a user account, transfering large sums of money.
    · Measures must be taken to prevent or circumvent brute force attacks. Measures could be a maximum number of login attempts, requiring a captcha after 5 failed logins attempts or throttling (slowing down) the system to make a brute force attack more difficult.

  • Passwords must be masked (not echoed to the screen) while the user enters the password.

  • Validate that a user is authorized to access every new page and for every action. Ensure that this is applied using whitelisting of approved users, not blacklisting of unapproved users. See blog post Pushing Left 5.1 for more information on whitelisting.

  • Never assume that “hiding” a page or feature means that it is protected or ‘safe’, that is not enough.

  • Login fails and errors should be logged. Ensure not to log sensitive information such as the text used for the attempted password, as it is likely only one or two characters off from the real password. Refer to blog post Pushing Left 5.9 for more information on what to log.

  • Brute force attempts (defined as 10 or more successive failed attempts to login in under 1 minute, or 100 or more failed attempts in one 24-hour period) must also be logged. If possible, the IP address of said attacker should be blocked, and account owner notified.

I realize that this list is not exhaustive, as this is a huge topic that could easily fill an entire book. I invite you, my readers, to provide more thoughts, topics and ideas in the comments section below. Thank you for reading.

Up next in the ‘Pushing Left, Like a Boss’ series: HTTPS only.

Pushing Left Like a Boss (23 Part Series)

1) Pushing Left, Like a Boss: Part 1 2) Pushing Left, Like a Boss! -- Part 2: Security Requirements 3 ... 21 3) Pushing Left, Like a Boss! -- Part 3: Secure Design 4) Pushing Left, Like a Boss: Part 4: Secure Coding 5) Pushing Left, Like a Boss — Part 5.1 — Input Validation, Output Encoding and Parameterized Queries 6) Pushing Left, Like a Boss — Part 5.2 — Use Safe Dependencies 7) Pushing Left, Like a Boss — Part 5.3 — Browser and Client-Side Hardening 8) Pushing Left, Like a Boss — Part 5.4 — Session Management 9) Pushing Left, Like a Boss — Part 5.5 — File Uploads 10) Pushing Left, Like a Boss — Part 5.6 — Redirects and Forwards 11) Pushing Left, Like a Boss — Part 5.7 — URL Parameters 12) Pushing Left, Like a Boss — Part 5.8 — Securing Your Cookies 13) Pushing Left, Like a Boss — Part 5.9 — Error Handling and Logging 14) Pushing Left, Like a Boss — Part 5.10 — Untrusted Data 15) Pushing Left, Like a Boss — Part 5.11 — Authorization (AuthZ) 16) Pushing Left, Like a Boss — Part 5.12 — Authentication (AuthN), Identity and Access Control 17) Pushing Left, Like a Boss — Part 5.13 — HTTPS only 18) Pushing Left, Like a Boss, Part 5.14 Secure Coding Summary 19) Pushing Left, Like a Boss - Part 6: Threat Modelling 20) Pushing Left, Like a Boss - Part 7: Code Review and Static Code Analysis 21) Pushing Left, Like a Boss - Part 8: Testing 22) Pushing Left, Like a Boss - Part 9: An AppSec Program 23) Pushing Left, Like a Boss - Part 10: Special AppSec Activities and Situations

Posted on by:

Microsoft Azure

Any language. Any platform.

Discussion

markdown guide