Secure Code
What a developer should know so that vulnerabilities do not appear in code: distrust of input, access, secrets, dependencies, working with scanner findings.
Everything that comes from outside could have been sent by an attacker: parameters, headers, files, responses of other APIs. Find the trust boundaries in the service: checks are needed exactly there.
Ten practices a developer applies on their own: input validation, access, cryptography, logging, safe libraries. A view from the other side of the OWASP Top 10: what to do rather than what to fear.
OWASP Top 10 is a regularly updated list of the most critical web application security risks from the OWASP community.
Check type, length, format and allowed values on the server. An allowlist is more reliable than a denylist.
SQL, OS commands, LDAP, templates. The defense is essentially the same: data separate from the command, that is, parameterized queries and safe APIs.
User data gets into the page and runs in the victim's browser. Encode output by context and do not disable the template engine's protection.
Foreign serialized objects and uploaded files allow code execution or planting a malicious file. Accept only expected formats and check the content.
Prompt injection, data leakage through the model, data poisoning, unsafe output. If a product uses LLMs or agents, this is an attacker's input like any other.
API security is the protection of the programming interfaces through which mobile apps, frontends and services communicate.
Password storage, MFA, brute-force protection, session lifetime and revocation.
Check permissions on every object, not only at the entrance to a section. Id substitution in a request (IDOR, BOLA) is a frequent finding in bank APIs.
Secret detection is a check of code and repository history for passwords, tokens, API keys, connection strings and private keys that ended up there.
Hash passwords with slow functions (Argon2id, bcrypt), protect traffic with TLS, and do not write your own cryptography.
SCA is a check of the libraries and dependencies an application is built from: whether the versions in use have known vulnerabilities (CVEs) and under which licenses the code is distributed.
CVE is the generally accepted identifier of a publicly known vulnerability in a specific product, for example CVE-2021-44228 (Log4Shell).
Pin versions in lock files, update deliberately, take packages from a trusted mirror.
A supply chain attack compromises not the application itself but what and with what it is built: libraries, build tools, package repositories, updates.
A short corporate document: what is mandatory in code and what is forbidden. The basis is the free OWASP Cheat Sheets and recommendations for your language. Secure code is a standard, not an option.
See findings in the editor and in the merge request, before review and release. SAST on every merge request, not a report before release: fixing a line right away is cheaper than returning to it a month later.
The cheapest first step: security rules in a linter catch typical mistakes right as the code is written, for example eslint-plugin-security for JavaScript and bandit for Python.
AI writes code faster but does not know the security context. Its code goes through the same SAST, SCA and secret detection, dependencies only through your own repository, critical places get human review. Secrets and personal data are not sent in a prompt.
A false positive is a scanner finding that is not actually a vulnerability: the data is already validated, the code is unreachable or the context makes the attack impossible.
A Quality Gate is an automatic checkpoint in the pipeline: if the check results do not meet the policy, the build does not go further.
Breaking practice applications is the fastest way to understand a vulnerability. Free: OWASP Juice Shop and PortSwigger Web Security Academy; then HackTheBox, TryHackMe and CTFs.
If an external service or a check fails, the system must deny, not let through (CWE-636). This applies to captcha, OAuth, antifraud and security steps in CI.
Give the user a short message and put the details in the log. A stack trace in the response tells the attacker how the system is built.
Log logins, access denials and money operations. Do not write passwords, tokens and excess personal data to the log.