Secure Code Warrior OWASP Web Top 10 2021 A1-A2 1: Broken Access Control and 2: Cryptographic Failures
Let’s start with the most critical application weaknesses. These challenges get you the foundations of 1: Broken Access Control and 2: Cryptographic Failures
Broken Access Control
Access Control - Missing Function Level Access Control
CRUD features for user accounts should be allowed to a limited circle of people who have access to system maintenance. For this, a role-based authorization mechanism has been applied with the [Authorize (Roles =" Admin ")]
attribute. The users without the "Admin" role won't get access to admin features since authorization middleware will restrict unauthorized requests.
Cross-site Request Forgery - Cross-site Request Forgery
The POST method is not protected against Cross-Site Request Forgery. The application does not differentiate between requests coming from the user's session or from another session. An attacker could therefore succeed in performing actions on behalf of other users. State-changing requests in particular, such as a password change or a purchase, are interesting to attackers.
The ValidateAntiForgeryToken attribute has been added above the POST method, so the application is properly protected against CSRF attacks. State-changing requests are properly protected this way. The application generates a unique and random token, and uses it to verify that the requests are legitimate.
Cryptographic Failures
Sensitive Data Storage - Plain Text Storage of Passwords
Passwords are stored as plain text in the database. If an attacker gains access to the database and key, all stored passwords will be compromised.
Passwords are hashed using Argon2 before they are stored in the database. Argon2 implementation automatically generates a safe hash for every password. It is a memory-hard password hashing function which not only make it computationally expensive, but it also uses a lot of memory (which can be configured). This means that it is much more difficult to attack Argon2 hashes using GPUs or dedicated hardware.
The system stores user passwords in plain text. Anyone who would gain access to the database will be able to get personal passwords of the users and use them for bad purposes.
It's recommended to use a modern password hashing algorithm such as Argon2. Argon2 is considered one of the strongest password encryption algorithms on the market.
Insufficient Transport Layer Protection - Unprotected Transport of Sensitive Information
Using the TLS encrypted protocol protects the personal data of users when they are sent to the server. But the wrong method of transmitting data is used so that user data still can be stored in browser history or server logs. Also, the application sends user data via the SMTP service to the user's email address without any protection, and this data can be stored for a long time. Consider finding a way not to send the user's data without any protection and not store them anywhere in the plain text without the consent of the user.
Using the TLS encrypted protocol protects the personal data of users when they are sent to the server. But the wrong method of transmitting data is used so that user data still can be stored in browser history or server logs. Also, the application sends user data via the SMTP service to the user's email address without any protection, and this data can be stored for a long time. Consider finding a way not to send the user's data without any protection and not store them anywhere in the plain text without the consent of the user.
Insufficient Transport Layer Protection - Unprotected Transport of Sensitive Information
The POST method is safe for sending user data to the server since it is sent in the request body; therefore, it is not stored in the server’s logs or the browser history. Also, the sending of personal data to the user's email without consent is not carried out; thereby, the data will not be saved without the user's actions outside the application.
作者:Chuck Lu GitHub |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
2021-10-16 炉石传说,佣兵战纪 技巧
2019-10-16 Are query string keys case sensitive?浏览器种输入url附带的参数是否区分大小写
2018-10-16 NOT IN clause and NULL values
2017-10-16 GitBlit中出现 error: remote unpack failed: error Missing tree
2015-10-16 default parameter value for ‘color’ must be a compile-time constant