Skip to content

Commit 1e2a9a3

Browse files
Merge pull request #151 from ossf/add_first_labs
Add links to initial labs
2 parents 02808dc + ba35e66 commit 1e2a9a3

File tree

1 file changed

+59
-1
lines changed

1 file changed

+59
-1
lines changed

secure_software_development_fundamentals.md

Lines changed: 59 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1362,7 +1362,6 @@ You also need to ensure that your system is not vulnerable to a “dependency co
13621362

13631363
🔔 Dependency confusion is a special case of 2021 CWE Top 25 #34, *Uncontrolled Search Path Element* ([CWE-427](https://cwe.mitre.org/data/definitions/427.html)). Relying on plugins, libraries, or modules from untrusted sources, and relying on untrustworthy content delivery networks, is considered part of 2021 OWASP Top 10 #8 (A08:2021), *Software and Data Integrity Failures*.
13641364

1365-
13661365
#### Quiz 3.2: Downloading and Installing Reusable Software
13671366

13681367
\>\>What are good ways to acquire software? Select all answers that apply.<<
@@ -1479,6 +1478,16 @@ First, make sure that you identify all inputs from potentially untrusted users,
14791478

14801479
At each remaining input from potentially untrusted users you need to validate the data that comes in. These input validation checks are a kind of security check, so you need to make sure that these input validation checks are non-bypassable, as we discussed earlier in the design principle *non-bypassability*. **As a reminder:** only trust security checks (including input validation) when they run on an environment you trust. This is especially important for JavaScript programs - since JavaScript can run on web browsers, it is easy to send security checks to the web browser and forget that *attackers* can control their own web browsers. Any input validation checks you do in an untrusted environment cannot be trusted. If you trust your server environment and not the client environment, then all security-relevant checks must be done in the server environment. We discussed this already, but it is important to emphasize because it is such a common and serious problem. Now let’s move on to how to actually validate input.
14811480

1481+
#### Lab: Input Validation Basics Introduction
1482+
1483+
🧪 Lab: This course includes some labs. Labs are optional, but you're *strongly* encouraged to try them! Please try lab [hello](https://best.openssf.org/labs/hello.html) to see how the labs work in this course.
1484+
1485+
IF a section has a quiz and one or more labs, we'll present the
1486+
quiz first. This order is intentional.
1487+
Quizzes help make sure you can *recognize* a correct answer,
1488+
while labs help you *create* a correct answer. Recognizing a correct answer
1489+
can be a first step towards creating your own.
1490+
14821491
### How Do You Validate Input?
14831492

14841493
You should determine what is legal, as narrowly as you reasonably can, and reject anything that does not match that definition. Using rules that define what is legal, and by implication rejecting everything else, is called *allowlisting* (the rules themselves are an *allowlist*). Synonyms are *goodlisting* (the rules are the *goodlist*) and the historically common *whitelisting* (the rules are the *whitelist*). In general, do not do the reverse. That is, it is normally a mistake to try to identify what is illegal and write code to reject just those cases. This generally insecure approach, where you try to list everything that should be rejected, is called *denylisting* (the rules are a *denylist*). Synonyms for denylisting are *badlisting* and the historically common *blacklisting* (the rules are then called a *badlist* or *blacklist*). Denylisting typically leads to security vulnerabilities, because if you forget to handle one or more important cases of illegal input, it could be an opportunity for an attacker. If you forget to allow a case, you get a bug report and your software fails securely. Besides, it is usually much easier to simply identify *what is allowed* and only allow those inputs. In a few rare cases you *can* absolutely be certain that you have enumerated all possible bad inputs, in which case denylisting is okay, but those are rare. Generally denylisting leads to trouble.
@@ -1543,6 +1552,11 @@ Many programs need to validate text fields, but those fields’ rules are not de
15431552

15441553
[x] Require that the number be an integer if that is the only expected kind of number.
15451554

1555+
#### Lab: Input Validation: A Few Simple Data Types
1556+
1557+
🧪 Lab: Please try lab [input1](https://best.openssf.org/labs/input1.html).
1558+
Labs are optional, but we encourage you to try them.
1559+
15461560
### Sidequest: Text, Unicode, and Locales
15471561

15481562
[[OPTIONAL]]
@@ -1671,6 +1685,11 @@ You can usually do a case-insensitive match through some option. Make sure you s
16711685

16721686
There is far more to regexes. In fact, there is a whole book on just regular expressions, [*Mastering Regular Expressions, 3rd Edition*](https://www.oreilly.com/library/view/mastering-regular-expressions/0596528124/), by Jeffrey Friedl (2006), and there are many tutorials on regexes such as the [Regular Expressions for Regular Folk](https://refrf.shreyasminocha.me/) tutorial by Shreyas Minocha. But that introduction will get us started, because we are now going to discuss how regexes can be used for input validation.
16731687

1688+
#### Lab: Introduction to Regular Expressions
1689+
1690+
🧪 Lab: Please try lab [regex0](https://best.openssf.org/labs/regex0.html), which lets you experiment with simple regex notation.
1691+
Labs are optional, but we encourage you to try them.
1692+
16741693
### Using Regular Expressions for Text Input Validation
16751694

16761695
Many programs need to quickly validate input text from untrusted sources. While there are many ways to do that, regexes are often an especially useful tool for input validation of text. Regexes are generally quick to write down (so they take very little development time), easy to use, and widely available. They’re also flexible enough for many input validation tasks, compact, and normally execute very quickly. They are also widely known and understood. These are important advantages; if writing input validation is too hard, it won’t be done. They don’t solve all possible input validation problems, but they are useful enough that they are important to know.
@@ -1747,6 +1766,14 @@ Remember, **^...$** are required to make this an allowlist (the text *must* matc
17471766

17481767
[Explanation]
17491768

1769+
#### Lab: Using Regular Expressions for Text Input Validation
1770+
1771+
🧪 Lab: Please try lab [regex1](https://best.openssf.org/labs/regex1.html), which lets you experiment using regex notation to validate strings.
1772+
1773+
🧪 Lab: Please try lab [input2](https://best.openssf.org/labs/input2.html), which lets you experiment in how to use a regex in a real program.
1774+
1775+
Labs are optional, but we encourage you to try them.
1776+
17501777
### Countering ReDoS Attacks on Regular Expressions
17511778

17521779
When you add code, there is a risk that the added code has a vulnerability. This is especially true when you add code that is supposed to help keep your software secure, since by definition, problems in that code could lead to a security problem.
@@ -1802,6 +1829,11 @@ Note: ReDoS is often *not* a real vulnerability. Such regexes can *only* be a vu
18021829

18031830
[ ] None of the above
18041831

1832+
#### Lab: Countering ReDoS Attacks on Regular Expressions
1833+
1834+
🧪 Lab: Please try lab [ReDoS](https://best.openssf.org/labs/redos.html), which lets you experiment in how to counter redos attacks in a real program.
1835+
Labs are optional, but we encourage you to try them.
1836+
18051837
## Input Validation: Beyond Numbers and Text
18061838

18071839
### Insecure Deserialization
@@ -2180,6 +2212,11 @@ A cast changes a value’s type (that is what it is *for*), so by itself that is
21802212

21812213
[Explanation]
21822214

2215+
#### Lab: Avoid Incorrect Conversion or Cast
2216+
2217+
🧪 Lab: Please try lab [conversion](https://best.openssf.org/labs/conversion.html), which lets you experiment in how to counter improper conversion.
2218+
Labs are optional, but we encourage you to try them.
2219+
21832220
## Processing Data Securely: Undefined Behavior / Memory Safety
21842221

21852222
### Countering Out-of-Bounds Reads and Writes (Buffer Overflow)
@@ -2294,6 +2331,11 @@ Correct. Of course, it is safer to not use memory-unsafe languages in the first
22942331

22952332
[Explanation]
22962333

2334+
#### Lab: Countering Out-of-Bounds Reads and Writes (Buffer Overflow)
2335+
2336+
🧪 Lab: Please try lab [oob1](https://best.openssf.org/labs/oob1.html), which lets you experiment in how to counter an out-of-bounds vulnerability.
2337+
Labs are optional, but we encourage you to try them.
2338+
22972339
### Double-free, Use-after-free, and Missing Release
22982340

22992341
[Memory-unsafe code]
@@ -2918,6 +2960,11 @@ This is true. Not only is it more efficient, but the operating system shell usua
29182960

29192961
[Explanation]
29202962

2963+
#### Lab: OS Command (Shell) injection
2964+
2965+
🧪 Lab: Please try lab [shell-injection](https://best.openssf.org/labs/shell-injection.html), which lets you experiment in how to counter an OS shell (injection) vulnerability.
2966+
Labs are optional, but we encourage you to try them.
2967+
29212968
### Other Injection Attacks
29222969

29232970
There are many other kinds of injection attacks beyond SQL injection and operating system command injection. There may be a risk of an injection attack any time you are sending data partly controlled by an untrusted user in a format that has metacharacters, is defined as a language, and/or is processed by an interpreter.
@@ -3127,6 +3174,11 @@ Error-handling is a fact of life, but you need to make sure your error handling
31273174

31283175
[x] If an exception is raised all the way to the “top” of a program (e.g., its event loop), you should typically log that exception, and then decide if the program will halt or continue.
31293176

3177+
#### Lab: Handling Errors
3178+
3179+
🧪 Lab: Please try lab [handling-errors](https://best.openssf.org/labs/handling-errors.html), which lets you experiment in how to counter an OS shell (injection) vulnerability.
3180+
Labs are optional, but we encourage you to try them.
3181+
31303182
### Logging
31313183

31323184
The best way to deal with attacks is to prevent them from having any effect. Sadly, as we noted earlier, sometimes attackers get through our prevention measures. In those cases, we need to detect the attack and then recover from it. Detection is vital, because we often won’t know to trigger recovery until we detect a problem.
@@ -3457,6 +3509,12 @@ This is true. CSP does not eliminate all problems, but CSP does let you forbid i
34573509

34583510
[Explanation]
34593511

3512+
#### Lab: Content Security Policy (CSP)
3513+
3514+
🧪 Lab: Please try lab [csp1](https://best.openssf.org/labs/csp1.html),
3515+
which lets you experiment with a Content Security Policy (CSP).
3516+
Labs are optional, but we encourage you to try them.
3517+
34603518
### Other HTTP Hardening Headers
34613519

34623520
[Web application]

0 commit comments

Comments
 (0)