Vulnerabilities, attacks, and mitigations
SecurityX CAS-005 · Lesson 22 of 24 · 3:24:54
YouTube loads only after you press play. This chapter opens at its timestamp in the full course. Watch on YouTube ↗
Learning with these videos? Subscribe for new courses and exam-style questions.
Subscribe on YouTube (opens in a new tab)In this lesson
Prepare for the CompTIA SecurityX (CAS-005) exam. In this lesson: injection, XSS, CSRF, and SSRF, unsafe memory, race conditions, and TOCTOU, insecure configuration, embedded secrets, and outdated software, deserialization, confused deputies, poisoning, and implants, and the mitigations and design principles that answer them. Includes three original practice questions, with Thornbury Biotech, a fictional biotech company whose security architect designs and runs its security, as the example.
Study notes
The text of this lesson, to read at your own pace. Information as of November 2026.
A penetration test report
Thornbury Biotech's yearly penetration test report lands with forty findings, from a web form that runs database commands to a password sitting in a script. The developers ask which ones matter most, and the admins ask which fixes cover several findings at once. This lesson groups the vulnerabilities by type, and pairs each with the mitigations that close it.
Web attacks
Injection happens when input is treated as code: SQL injection changes a database query, and command injection runs operating system commands, so use parameterized queries, and never build commands from raw input. Cross-site scripting, or XSS, plants script in a page that other users load, so it runs in their browsers with their sessions, and output encoding, which turns special characters into harmless text for each context, is the main defense. Cross-site request forgery, or CSRF, tricks a signed-in user's browser into sending an unwanted request, so require anti-forgery tokens and same-site cookies for every action that changes state. Server-side request forgery, or SSRF, makes a server fetch an address chosen by the attacker, often an internal service, or a cloud metadata endpoint that hands out credentials. Input validation on the server, with allow lists of expected formats, supports all of these defenses, but it never replaces parameterized queries and output encoding.
Memory and timing flaws
Unsafe memory use, in languages like C and C++, leads to buffer overflows that write past the end of a buffer, and to use after free, where freed memory is used again, and both can let attackers run code. Integer overflows wrap a number around, so a size check passes when it should fail, which often leads to a buffer overflow. Deprecated functions, like unbounded string copies, are known to be unsafe, so compilers and linters should flag them, and memory safe languages like Rust, Go, Java, or C sharp remove whole classes of these flaws. A race condition occurs when the result depends on timing between threads or processes, and time of check, time of use, or TOCTOU, is the classic case: a file is checked, then swapped before it is used. Safe functions remove these gaps: atomic functions check and act in one indivisible step, thread safe functions handle concurrent calls correctly, and memory safe functions enforce bounds.
Configuration and secrets
Insecure configuration is the most common flaw of all: default accounts, open admin interfaces, verbose error messages, public storage, and debug modes left on in production. Directory service misconfigurations, like too many domain admins, passwords that never expire, weak delegation settings, or service accounts open to Kerberoasting, give attackers a fast path to the whole domain. Embedded secrets, like keys or passwords in source code, images, or scripts, end up in repositories and backups, so scan for them, move them to a secrets manager, and rotate any key that was exposed. Key rotation limits the damage of a leak, and automated rotation makes it routine instead of an outage. Weak ciphers, like outdated protocol versions, short keys, or deprecated modes, survive in old configurations, so scan endpoints regularly, and disable them in central policies.
Patching and the supply chain
Outdated and unpatched software is still a top way in, so patch every layer: operating systems, applications, hypervisors, firmware, and the system images that new machines are built from. A patched server rebuilt from an old image is unpatched again, so refresh golden images on a schedule. End-of-life software gets no more fixes at all, so replace it, or isolate it with compensating controls and an accepted risk, until it is gone. Vulnerable third parties and libraries bring flaws you did not write, so dependency management keeps an SBOM, pins versions, watches advisories, and upgrades components through the pipeline. Code signing then confirms that each component and each release really comes from its publisher, unchanged.
Attacks on trust
Insecure deserialization rebuilds objects from untrusted data, and a crafted object can run code as it is loaded, so accept only simple data formats, or verify a signature before deserializing. A confused deputy is a privileged component tricked into using its rights for someone else, like a cloud service that accesses any account a caller names, so check the caller's authority, not just your own. Poisoning corrupts something others trust: DNS cache poisoning redirects users, ARP poisoning intercepts local traffic, and data poisoning slips bad samples into the training data of an AI model. Implants are hidden code or hardware left behind for persistence, like a backdoor in firmware, a malicious library, or a rogue device on the network, and they survive ordinary cleanup. Detecting them takes integrity checks against known good baselines, firmware verification, and network monitoring for unexpected beacons.
Design principles
Security design patterns, like a single validated entry point, centralized authorization checks, and well reviewed libraries for authentication and cryptography, prevent whole classes of flaws. Least privilege limits what any account or component can do, and least functionality removes features, services, and ports that are not needed. Fail secure means that a failure leaves things locked, like a firewall that blocks traffic when it crashes, while fail safe protects people first, like doors that unlock during a fire. Defense in depth layers controls, like allow listing, encryption, and monitoring, so one failure does not open everything. Indexing helps in two ways: indexed databases stay fast under heavy queries, which blunts resource exhaustion, and a searchable index of code and components finds every place where a new flaw appears.
Recap
Let's recap. Injection, cross-site scripting, and request forgery on both sides call for parameterized queries, output encoding, tokens, and validation. Overflows, unsafe memory, deprecated functions, race conditions, and TOCTOU call for atomic, thread safe, and memory safe functions. Insecure configurations, directory mistakes, embedded secrets, and weak ciphers call for hardening, vaults, rotation, and scans, while every layer needs patching, and dependencies need management and signing. Deserialization, confused deputies, poisoning, and implants abuse trust, and integrity checks expose them. And design patterns, least privilege, least functionality, fail secure or fail safe, defense in depth, indexing, and allow listing hold it all together.
Quick checks for this lesson
The 3 questions of this lesson, as plain text. The button above runs them with shuffled choices and the reason behind every choice.
A Thornbury web app takes an image address from users and downloads the image from the server, and a tester makes it fetch the cloud metadata service, which returns temporary credentials. What is this attack?
- Server-side request forgery
- Cross-site request forgery
- Cross-site scripting
- A race condition
Show the answer
Server-side request forgery
The attacker makes the server itself fetch an internal address, here the metadata service that hands out credentials. “Cross-site request forgery” would abuse a user's browser, not the server. “Cross-site scripting” would run script in other users' browsers. And “A race condition” is about timing between operations.
A scanner finds an API key for Thornbury’s payment provider inside a script in a public code repository, committed six months ago. What should the team do first?
- Delete the script from the latest version
- Make the repository private and move on
- Revoke and rotate the key, then use a vault
- Add a comment in the script asking people not to use it
Show the answer
Revoke and rotate the key, then use a vault
The key has been public for months, so treat it as compromised, revoke and replace it, and keep the new one in a secrets manager. “Delete the script from the latest version” would leave the key in the repository history. “Make the repository private and move on” would not undo six months of exposure. And “Add a comment in the script asking people not to use it” would do nothing to stop someone who already copied it.
A badge-controlled door at Thornbury’s chemical store must stay locked if its controller loses power, while the emergency exits of the same building must open in a fire. Which principles apply to each?
- Fail safe for the store, fail secure for the exits
- Fail secure for the store, fail safe for the exits
- Least functionality for both doors
- Defense in depth for the store only
Show the answer
Fail secure for the store, fail safe for the exits
The store's door fails secure, staying locked to protect its contents, while the exits fail safe, opening to protect people. “Fail safe for the store, fail secure for the exits” is the reverse, which would endanger people and expose the chemicals. “Least functionality for both doors” is about removing unneeded features, not about failure behavior. And “Defense in depth for the store only” is about layering controls, and it says nothing about how a door fails.