Learn how to secure networks, applications, and systems against digital threats.
Secure coding is writing software so that it is hard to misuse: validating input, encoding output, parameterizing queries, checking authorization, and failing safely. Static Application Security Testing (SAST) and related tooling catch these mistakes early, in the development workflow, before they reach production. This lesson covers the principles of security by design, the specific coding patterns that prevent common vulnerabilities, and the tooling — SAST, DAST, and SCA — that automates finding them, plus how false positives and false negatives shape remediation. The code examples are deliberately vulnerable then fixed, using small, self-contained Python so you can see the exact difference.
Parameterized queries separate code from data so the database never interprets input as SQL.
| Tool | Analyzes | When it runs | Finds |
|---|---|---|---|
| SAST | Source code / bytecode | During development/CI | Injection, hardcoded secrets, unsafe patterns |
| DAST | A running application | Against a deployed/test instance | Runtime flaws, misconfigurations, exposed endpoints |
| SCA | Third-party dependencies | During build | Known vulnerabilities in libraries |
SAST looks at code, DAST tests the running application, and SCA checks dependencies. They are complementary, not interchangeable.
Passing an argument list (instead of a single shell string) prevents the shell from interpreting user input as commands.
Rendering untrusted text safely.
<script>alert(1)</script>
A bug in a dependency is invisible to SAST.
(match the tool to the layer it analyzes)