Skip to content

Commit 121d06c

Browse files
committed
review-1
1 parent 4978153 commit 121d06c

13 files changed

+76
-74
lines changed

learn-pr/aspnetcore/owasp-top-10-for-dotnet-developers/3-broken-access-control.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ quiz:
2121

2222
- content: "The goal of the Open Web Application Security Project (OWASP) Top 10 report put together by security experts is to:"
2323
choices:
24-
- content: "Create a standard for security benchmark of web applications."
24+
- content: "Create a standard security benchmark for web applications."
2525
isCorrect: false
26-
explanation: "Incorrect. OWASP Top 10 is often effort to be an 'awareness document' for educational purposes."
27-
- content: "Improve awareness and promote recommended mitigation techniques to most critical security concerns for web app security."
26+
explanation: "Incorrect. OWASP Top 10 is primarily an 'awareness document' for educational purposes."
27+
- content: "Improve awareness and promote recommended mitigation techniques to the most critical security concerns for web app security."
2828
isCorrect: true
2929
explanation: "Correct."
3030
- content: "Be the only go-to report your organization would need to stay secured."

learn-pr/aspnetcore/owasp-top-10-for-dotnet-developers/5-injection.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ quiz:
1818
questions:
1919
- content: "In modern day .NET, how can the code fragment `string sql='SELECT * FROM users WHERE name = '\" + username + \"'` be written more securely?"
2020
choices:
21-
- content: "Using an object relational mapper (ORM)."
21+
- content: "By using an object relational mapper (ORM)."
2222
isCorrect: false
23-
explanation: "Entity Framework with LINQ is a powerful way of querying many relational database engines."
24-
- content: "Using stored procedures."
23+
explanation: "Using Entity Framework with Language Integrated Query (LINQ) is a powerful way of querying many relational database engines."
24+
- content: "By using stored procedures."
2525
isCorrect: false
2626
explanation: "Stored procedures are the most effective way of countering the SQL Injection vulnerability."
27-
- content: "Using parameterized queries."
27+
- content: "By using parameterized queries."
2828
isCorrect: false
2929
explanation: "Use parameterized queries where a direct SQL query must be used."
30-
- content: "You should use at least one or combinations of few techniques, including Entity Framework and input validation"
30+
- content: "You should use at least one or a combination of a few techniques, including Entity Framework and input validation."
3131
isCorrect: true
3232
explanation: "With username validation as a minimum, you can use any of the methods."

learn-pr/aspnetcore/owasp-top-10-for-dotnet-developers/8-vulnerable-outdated-components.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ quiz:
1818
questions:
1919
- content: "How should the DevOps team maintain and review a list of third-party components used in the system for security vulnerabilities?"
2020
choices:
21-
- content: "An Excel spreadsheet with Software Bill of Materials should be part of the design phase and any new green field project."
21+
- content: "An Excel spreadsheet with Software Bill of Materials (SBOM) should be part of the design phase and any new green field project."
2222
isCorrect: false
2323
explanation: "SBOM is recommended, but you can apply it at any stage of the project in a more automated fashion."
24-
- content: "Favor automated tools at any stage of the product lifecycle to track and monitor your dependencies."
24+
- content: "By favoring automated tools at any stage of the product lifecycle for tracking and monitoring dependencies."
2525
isCorrect: true
2626
explanation: "Correct. The maintenance effort required to keep a list of dependencies up to date combined with their vulnerability checks can quickly become unmanageable."
27-
- content: "There's no risk associated with third-party purchased and OSS components."
27+
- content: "There's no risk associated with third-party purchased and Operational support system (OSS) components."
2828
isCorrect: false
29-
explanation: "Even if your software makes the best effort in staying secure, an insecure or flow dependency may introduce security vulnerability in your system."
29+
explanation: "Even if your software makes the best effort in staying secure, an insecure or flow dependency might introduce security vulnerability in your system."

learn-pr/aspnetcore/owasp-top-10-for-dotnet-developers/9-identification-authentication-failures​.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ quiz:
2020
- content: "Find the authors of the change with git blame and ask them to fix it when they have some spare time."
2121
isCorrect: false
2222
explanation: "Chances are that whoever checked in the commit might no longer be part of your team or even the same company."
23-
- content: "Change the password for the username referenced in connection string. Open a pull request with hardcoded connection string now being obtained from Azure KeyVault."
23+
- content: "Change the password for the username referenced in the connection string. Open a pull request with the hardcoded connection string now being obtained from Azure KeyVault."
2424
isCorrect: true
2525
explanation: "Secret rotation is a good practice. Azure KeyVault is the go-to service for storing secrets, certificates, and keys and in most secure fashion. Avoid blame games."
2626
- content: "The connection string is only referenced in Git and code. No one can access it because only the web app is available to the public, so nothing needs to be done."
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11

2-
This module explores OWASP TOP 10: 2021 edition. It covers the most common security weaknesses and how you as an app developer or architect can reduce the risk of security bugs infecting your systems. This module introduces techniques, tools, and best practices that can improve your product’s security posture.
2+
This module explores the OWASP TOP 10: 2021 edition. It covers the most common security weaknesses and how you as an app developer or architect can reduce the risk of security bugs infecting your systems. This module introduces techniques, tools, and best practices that can improve your product’s security posture.
33

44
### Threat landscape
55

6-
Implementing secure and high-quality software can be challenging. Malware, exploits, and many other cyber threats are on the rise. Attacks happen by exploiting vulnerabilities in an application. A vulnerability is just an unintended flaw or weakness in that application. How data is processed and stored and how services are configured are examples of where a vulnerability could be introduced.
6+
Implementing secure and high-quality software can be challenging. Cyber threats are on the rise, like malware, exploits, and many others. Attacks happen by exploiting vulnerabilities in an application. A vulnerability is just an unintended flaw or weakness in that application. How data is processed and stored and how services are configured are examples of where a vulnerability could be introduced.
77

88
![Diagram showing interconnected elements of modern system.](../media/appsec.png)
99

10-
News stories about a company being hacked or data being stolen and posted on dark web are now common. According to the 2021 Identity Theft Resource Center (ITRC) Annual Data Breach Report, the cost of a data breach increased by nearly 10% between 2020 and 2021. Data breaches are increasing and getting more costly.
10+
News stories about a company being hacked or data being stolen and posted on the dark web are now common. According to the 2021 Identity Theft Resource Center (ITRC) Annual Data Breach Report, the cost of a data breach increased by nearly 10% between 2020 and 2021. Data breaches are increasing and getting more costly.
1111

1212
> [!IMPORTANT]
13-
> NIST defines [Software Vulnerability](https://csrc.nist.gov/glossary/term/Software_Vulnerability) as security flaw, glitch, or weakness found in software code that could be exploited by an attacker (threat source).
13+
> The National Institute of Standards and Technology (NIST) defines [Software Vulnerability](https://csrc.nist.gov/glossary/term/Software_Vulnerability) as "a security flaw, glitch, or weakness found in software code that could be exploited by an attacker (threat source)."
1414
1515
### The world of application security
1616

@@ -21,20 +21,20 @@ Application Security, often referred to as AppSec, is the process of finding, fi
2121
![Diagram showing world's biggest data breaches and hacks.](../media/worlds-breaches.png)
2222
[Image source](https://www.informationisbeautiful.net/visualizations/worlds-biggest-data-breaches-hacks/)
2323

24-
AppSec logically falls under the wider context of **Information Security (InfoSec)**, term covering protection of information and systems from unauthorized access, use, disruption, or destruction. InfoSec also covers areas like as network security, intrusion detection, digital forensics, and governance, risk, and compliance, for example.
24+
AppSec logically falls under the wider context of **Information Security (InfoSec)**, a term covering the protection of information and systems from unauthorized access, use, disruption, or destruction. InfoSec also covers areas like network security, intrusion detection, digital forensics, and governance, risk, and compliance, for example.
2525

2626
**The Security Development Lifecycle (SDL)** consists of a set of practices that support security assurance and compliance requirements. The SDL helps developers build more secure software by reducing the number and severity of vulnerabilities in software.
2727

2828
**DevSecOps** is an evolution in the way development organizations approach security by introducing a security-first mindset culture and automating security into every phase of the software-development lifecycle from design to delivery.​
2929

3030
### Meet the team
3131

32-
Suppose you're joining a new IT company with an established team working on a legacy software. Your team's main focus is maintaining, supporting, and developing new features of a rich web application that customers all around the world use. The website and its underlying infrastructure have only recently been migrated to Microsoft Azure cloud.
32+
Suppose you're joining a new IT company with an established team working on a legacy software. Your team's main focus is maintaining, supporting, and developing new features of a rich web application that customers all around the world use. The website and its underlying infrastructure were only recently migrated to Microsoft Azure cloud.
3333

3434
The team you're part of has a mix of talent, including early-career and seasoned enterprise developers.
3535

36-
In the past, your team was slowed down by the manual-release process that proved to be unreliable, error-prone, and heavy on manual interaction. As part of its cloud migration, your team is looking to adopt modern CI/CD automation.
36+
In the past, a manual-release process slowed down your team and proved to be unreliable, error-prone, and heavy on manual interaction. As part of its cloud migration, your team is looking to adopt modern CI/CD automation.
3737

38-
The company hasn't fully grasped the concepts behind secure DevOps practices. With new personnel onboarded, the company is looking to spread security best practices not only within the team, but the company as a whole.
38+
The company has yet to fully grasp the concepts behind secure DevOps practices. With new personnel onboarded, the company is looking to spread security best practices not only within the team, but the company as a whole.
3939

4040
Your team lead asked you to conduct design and code reviews of a team-owned codebase, with extra attention paid to the solution's security aspects. You discovered the OWASP report, which you plan to use as a reference in your code review.

learn-pr/aspnetcore/owasp-top-10-for-dotnet-developers/includes/2-what-is-owasp-top-10.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
2-
As application complexity increases, so does the effort of making it secure. Modern applications (in contrast with single-project monolith legacy applications) have many dependencies, including external libraries, services for hosting, building, and releasing, to name a few. None of these services are simple "plug and play" affairs. Developers need to understand them and know how to configure and implement the flows and processes securely in their own code.
1+
As application complexity increases, so does the effort of making it secure. Modern applications, in contrast with single-project monolith legacy applications, have many dependencies. Including, external libraries, services for hosting, building, and releasing, to name a few. None of these services are simple "plug and play" affairs. Developers need to understand them and know how to configure and implement the flows and processes securely in their own code.
32

43
:::row:::
54
:::column span="2":::
@@ -14,7 +13,7 @@ As application complexity increases, so does the effort of making it secure. Mod
1413
:::column-end:::
1514
:::row-end:::
1615

17-
Although security is everyone’s job, it's important to remember that not everyone needs to be a security expert nor strive to become a proficient penetration tester. However, ensuring everyone understands the attacker's perspective, their goals, and the art of the possible will help capture the attention of everyone and raise the collective knowledge bar.
16+
Although security is everyone’s job, it's important to remember that not everyone needs to be a security expert nor strive to become a proficient penetration tester. However, ensuring everyone understands the attacker's perspective, their goals, and the art of the possible, helps capture the attention of everyone and raise the collective knowledge bar.
1817

1918
### What is OWASP?
2019

learn-pr/aspnetcore/owasp-top-10-for-dotnet-developers/includes/3-broken-access-control.md

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
Recall that you recently joined a team at an IT software company that's tasked you with conducting a design and code review of the team-owned codebases. As you onboard to your new team and explore the codebase, you discover an ASP.NET Blazor web project. With OWASP Top 10 in mind, you set off on a deep dive into the code with your security lenses on.
2+
Recall that you recently joined a team at an IT software company who tasked you with conducting a design and code review of the team-owned codebases. As you onboard to your new team and explore the codebase, you discover an ASP.NET Blazor web project. With OWASP Top 10 in mind, you set off on a deep dive into the code with your security lenses on.
33

44
You start at the top of the OWASP Top 10 list with *#1: Broken Access Control*. This category refers to incidents where a user who shouldn’t have permission to access that data viewed confidential information.
55

@@ -11,8 +11,8 @@ Let's consider a ASP.NET Core controller. A controller without any authorization
1111
:::row:::
1212
:::column:::
1313
Plain ASP.NET controller with no authorization attributes, no access restrictions applied.
14-
```csharp
1514

15+
```csharp
1616
public class AccountController : Controller
1717
{​
1818
public ActionResult Login()​
@@ -27,12 +27,12 @@ public class AccountController : Controller​
2727
{
2828
}
2929
}
30-
3130
```
3231

3332
:::column-end:::
3433
:::column:::
3534
Controller with authorization attributes, based on policy or role assignments. Authorized caller is able to invoke the `GetCitizenTaxId` method.
35+
3636
```csharp
3737
[Authorize(Policy="", Roles=""]​
3838
public class AccountController : Controller
@@ -56,23 +56,26 @@ public class AccountController : Controller​
5656
:::column-end:::
5757
:::row-end:::
5858

59-
Similarly, the ASP.NET Minimal API supports the attribute decoration (Lambda *HTTP get* method with `[Authorize]` attribute), policy (`AdminsOnly`) and claim (`admin`) authorization, as shown here:
59+
Similarly, the ASP.NET Minimal API supports the attribute decoration (Lambda *HTTP get* method with `[Authorize]` attribute), policy (`AdminsOnly`), and claim (`admin`) authorization, as shown here:
6060

61-
> ```csharp
62-
> var builder = WebApplication.CreateBuilder(args);​
63-
>// Policy and claim use below
64-
>builder.Services.AddAuthorization(o => o.AddPolicy("AdminsOnly", b => b.RequireClaim("admin", "true")));
65-
> var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");​
66-
> builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(connectionString)); ​
67-
> builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true).AddEntityFrameworkStores<ApplicationDbContext>(); ​
68-
> var app = builder.Build(); ​
69-
> app.UseAuthorization();​
70-
> // Attribute use below
71-
> app.MapGet("/auth", [Authorize] () => "This endpoint requires authorization.");​
72-
> app.MapGet("/", () => "This endpoint doesn't require authorization.");​
73-
> app.Run();
61+
```csharp
62+
var builder = WebApplication.CreateBuilder(args);​
63+
64+
// Policy and claim use below
65+
builder.Services.AddAuthorization(o => o.AddPolicy("AdminsOnly", b => b.RequireClaim("admin", "true")));
66+
var connectionString = builder.Configuration.GetConnectionString("DefaultConnection");​
67+
builder.Services.AddDbContext<ApplicationDbContext>(options => options.UseSqlServer(connectionString)); ​
68+
builder.Services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = true).AddEntityFrameworkStores<ApplicationDbContext>(); ​
69+
var app = builder.Build(); ​
70+
app.UseAuthorization();​
71+
72+
// Attribute use below
73+
app.MapGet("/auth", [Authorize] () => "This endpoint requires authorization.");​
74+
app.MapGet("/", () => "This endpoint doesn't require authorization.");​
75+
app.Run();
76+
```
7477

75-
Your application's user interface should also reflect the user's authentication (the user is who they say they are) and authorization state (whether the user is allowed to access certain information). Here, too, the OWASP Top 10 framework has you covered. ASP.NET Blazor's razor syntax supports conditionally displayed components depending on authorization status. The `AutorizeView` component selectively displays UI content based on user's authorized status.
78+
Your application's user interface should also reflect the user's authentication (the user is who they say they are) and authorization state (whether the user is allowed to access certain information). Here, too, you're covered by the OWASP Top 10 framework. ASP.NET Blazor's razor syntax supports conditionally displayed components depending on authorization status. The `AutorizeView` component selectively displays UI content based on user's authorized status.
7679

7780
```csharp
7881
<AuthorizeView Roles="admin, superuser">
@@ -100,7 +103,7 @@ The `SecureMethod` is accessible once the user is authorized. Because the `Autor
100103

101104
### Code review notes
102105

103-
You and your team have considered the broken access control risk and implemented Claims-based and Policy-based authorization in your web app. Knowing the app gets deployed to Azure, other best practices include:
106+
You and your team considered the broken access control risk and implemented Claims-based and Policy-based authorization in your web app. Knowing the app gets deployed to Azure, other best practices include:
104107

105-
- Authorize users on all externally facing endpoints.
106-
- Use role-based and policy-based authorization in your application. ASP.NET has many ways to authorize a userbased on their role or claims.
108+
- Authorizing users on all externally facing endpoints.
109+
- Using role-based and policy-based authorization in your application. ASP.NET has many ways to authorize a userbased on their role or claims.

learn-pr/aspnetcore/owasp-top-10-for-dotnet-developers/includes/4-cryptographic-failures.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Your web applications deal with user accounts and data, but how do you securely
1515

1616
### Encryption
1717

18-
To securely encrypt a value like a string or integer, you can use symmetric or asymmetric encryption. To encrypt data with a symmetric-key algorithm, you can use the Advanced Encryption Standard (AES). In the next example, we create new instance of the `Aes` class and use it to generate a new key and initialization vector (IV).​ We use the AES to encrypt any type of managed stream. The stream is then wrapped with `CryptoStream`.
18+
To securely encrypt a value like a string or integer, you can use symmetric or asymmetric encryption. To encrypt data with a symmetric-key algorithm, you can use the Advanced Encryption Standard (AES). In the next example, we create a new instance of the `Aes` class and use it to generate a new key and initialization vector (IV).​ We use the AES to encrypt any type of managed stream. The stream is then wrapped with `CryptoStream`.
1919

2020
```csharp
2121
Aes aes = Aes.Create();​

0 commit comments

Comments
 (0)