Authentication Guidelines - Developer's Perspective

0 22
Most developers should be familiar with authentication. Routine weak password is...

Most developers should be familiar with authentication. Routine weak password issues and authentication-related vulnerabilities arise frequently. Today, I am mainly looking at how to ensure secure development for authentication from the perspective of research and development, or how to select appropriate authentication scenarios to ensure the security of application system authentication.

Authentication is the process of verifying whether an individual, entity, or website is consistent with the identity claimed. Common scenarios involve verification through submission of username or ID and password. After authentication, interaction management is conducted through sessions. Session management is the process by which the server maintains the state of entities with which it interacts. This is essential for the server to remember how to respond to subsequent requests in the transaction process. Sessions are maintained through session identifiers on the server, which can be passed back and forth between the client and server during the transmission and reception of requests. Sessions should be unique for each user and difficult to predict.

AuthenticationGuidelines - Developer's Perspective

User ID

Authentication Guidelines - Developer's Perspective

Ensure that usernames/user IDs are case-insensitive. Users 'smith' and 'Smith' should be considered the same user. Usernames should also be unique. For applications with high security requirements, usernames should be assigned and kept confidential by the system, rather than being publicly customizable data set by the users.

Authentication Solutions and Sensitive Accounts

  • It is not allowed to log in to any front-end user interface using sensitive accounts (i.e., internal accounts such as those used for backend/middleware/database).

Implement password strength control

Weak password issues arise frequently. It is necessary to enforce password policies at the application layer to reduce the risk of users setting weak passwords. Specific characteristics are as follows:

Password Length

  • The application should enforce the minimum password length. It should be no less than 8 characters.
  • The application should enforce the maximum password length. It should not exceed 64 characters, as passwords longer than 64 characters may be susceptible to long password denial-of-service attacks.

Do not silently truncate passwords

Allow the use of all characters, including Unicode and spaces

  • There should not be password composition rules that limit the allowed character types.

Implement a secure password recovery mechanism

Applications usually have a mechanism that provides users with a way to access their account when they forget their password.

Securely store passwords

The application uses the correct encryption technology to store passwords, which is complex and will be explained in a special topic later.

Use secure functions to compare password hashes

Use the secure password comparison functions provided by the language or framework to compare the password entered by the user with the stored password hash, for example, the `password_verify()` function in PHP. Make sure that the comparison function:

  • Has the maximum input length to prevent denial of service attacks caused by very long inputs.
  • Explicitly set the types of two variables to prevent type confusion attacks such as magic quotes in PHP.
  • Returns in constant time to prevent timing attacks.

Only through TLS-level encryptionTransmission method transmits password

Sensitive features require re-authentication

To prevent CSRF attacks and session hijacking, re-enter the current account credentials for secondary verification before updating sensitive account information (such as user password, user email) or performing sensitive transactions. It is common to verify the old password when changing passwords. Without this measure, attackers may be able to execute sensitive transactions through CSRF or XSS attacks without knowing the user's current credentials. In addition, attackers may take over the user's session by temporarily accessing the user's browser physically or by stealing their session ID.

Two-factor authentication

The application should use two-factor authentication for sensitive operations. For example, a second verification is required when logging in from a new or untrusted device.

Authentication and error messages

In the case of authentication functionality, if the error message implementation is incorrect, it can be used for user ID and password enumeration. The application should respond to the following situations using general error messages (including HTTP and HTML):

  • User ID or password is incorrect.
  • Account does not exist.
  • Account is locked or disabled.

The account registration feature should also be considered. For existing users, the same general error message method can be applied to prevent attackers from performing user enumeration operations on the application.

However, the business logic itself may introduce factors related to processing time. In fact, depending on the implementation, processing time may vary significantly in different situations (success and failure), such as time-based attacks by attackers (for example, a few seconds difference).

Example of login functionality using pseudocode:

The first implementation uses the 'quick exit' method

```plaintext

IF USER_EXISTS(username) THEN

password_hash=HASH(password)

IS_VALID=LOOKUP_

你可能想看:

Data security can be said to be a hot topic in recent years, especially with the rapid development of information security technologies such as big data and artificial intelligence, the situation of d

d) Adopt identification technologies such as passwords, password technologies, biometric technologies, and combinations of two or more to identify users, and at least one identification technology sho

Comprehensive Guide to Linux Two-factor Identity Authenticationssh + console + graphical interface

Ensure that the ID can be accessed even if it is guessed or cannot be tampered with; the scenario is common in resource convenience and unauthorized vulnerability scenarios. I have found many vulnerab

b) It should have the login failure handling function, and should configure and enable measures such as ending the session, limiting the number of illegal logins, and automatically exiting when the lo

In today's rapidly developing digital economy, data has become an important engine driving social progress and enterprise development. From being initially regarded as part of intangible assets to now

b) It should have a login failure handling function, and should configure and enable measures such as ending the session, limiting the number of illegal login attempts, and automatically logging out w

1. Send authentication and scheduled task logs (auth, authpriv, cron)

Building a test environment requires caution! What points should be paid attention to before and after building it?

Camera intrusion, inciting suicide, guiding to graveyards... How far is the road to AI intelligent security?

最后修改时间:
admin
上一篇 2025年03月27日 09:49
下一篇 2025年03月27日 10:12

评论已关闭