How it works
Applications can be attacked through weak input handling, broken access control, unsafe configuration, exposed secrets, or missing logs.
Prefer input validation, safe query methods, permission checks, logging, backups, and incident response steps that match the evidence.
Common error
Do not publish logs that contain sensitive data. Logs help defenders, but they must be protected too.
Topic 5.1: Application and data risk notes and evidence practice
Follow a fictional Lumen Community Gallery as it reviews a catalog, shared files, visitor comments, and an older import utility. Examples connect a specific weakness to an observable result and an appropriate control. All records and measurements are invented teaching examples. Original foundation lessons, exercises, and downloads remain available.
5.1 Application and Data Vulnerabilities and Attacks
Identify the asset, the trust boundary, and the action an application permits before naming the attack. File permissions, database queries, browser rendering, memory copies, and file paths fail in different ways. Explain the confidentiality, integrity, or availability consequence supported by the evidence, then assess likelihood and impact in context.
Read topic 5.1 notes, evidence, and quick checks
5.1.A: Plaintext files and readable copies
A readable unencrypted file may disclose its contents to someone who obtains sufficient access to that file or its storage. Operating-system permissions help control normal access, but may not protect a removable drive read outside the original operating system. Appropriate encryption with separately protected keys reduces exposure of a stolen locked device. It does not protect a file from an account already permitted to open it, or a readable export copied elsewhere. Physical possession alone does not establish that every file was read; identify the actual access and evidence.
Excess privileges expand the consequences of account compromise
A routine user with unnecessary administrator rights gives a compromised account more opportunities to change settings, install software, and access local resources. A database or application service account with unnecessary write rights can similarly expand the damage from an application flaw. Scope matters: local administrator access does not automatically confer every remote service role or decrypt every separately protected file. Remove unnecessary privilege and test required work through approved, limited elevation rather than assuming a role label proves unlimited control.
Read, edit, delete, and share are different permissions
Review the effective access of users, groups, service identities, public links, and inherited folders. A read-only exposure can compromise confidentiality; unauthorized editing compromises integrity; deletion or service disruption can compromise availability. A signed-in user still needs permission for the particular record and action. Check both the expected allowed case and the denied case, including stale membership and shared links. Hiding a button or changing a file name does not enforce authorization.
Follow data through storage, transfer, use, and backups
A protected transfer can end in a readable download, temporary file, log, or backup. Encryption at rest, protected transport, key access, application authorization, and retention address different parts of that path. A login screen does not prove a drive is encrypted, and encryption does not repair public edit permissions. Inventory copies and recovery access as well as the primary database. Do not place real sensitive records in a diagnostic example merely to demonstrate a vulnerability.
5.1.B: Locate the interpreter and the trust boundary
An application executes instructions and processes data. A web application commonly spans browser code, server logic, databases, storage, and supporting services; not every part executes on the server. Untrusted values may arrive through forms, requests, uploaded files, saved comments, or external services. SQL injection changes a database command; XSS reaches a browser interpretation context; a memory-safety flaw affects a program buffer; traversal influences a file operation. Identify the receiving component before choosing a control.
Validation, authorization, and safe interpretation solve different problems
Server-side validation checks expected type, range, length, and format, and can enforce business rules. Client checks improve usability but can be bypassed by a direct request. Validation alone does not separate SQL commands from data, make arbitrary HTML safe, or decide who may read a valid record ID. Pair it with safe APIs and per-operation authorization. Legitimate names and comments may contain punctuation; rejecting every quote is not a complete injection defense. Choose an explicit contract for each input and destination.
Keep SQL command structure separate from values
SQL injection occurs when an untrusted value can change the structure or logic of a database statement. Direct string concatenation can make a filter return records outside its intended scope. Prepared statements with bound parameters keep supplied values in data positions instead of interpreting them as SQL syntax. Retain the server-owned scope and permission conditions as well. Parameter markers generally do not select table names, column names, or sort directions; those structural choices need a fixed mapping or allowlist.
Describe the database result that the evidence supports
An injection that exposes extra rows is a confidentiality problem. Modification, deletion, or disruption may also be possible if the vulnerable operation, database privileges, and engine or driver behavior permit them. A read-only example does not demonstrate a successful write or automatic execution of multiple statements. Restricted service-account permissions limit impact but do not repair the unsafe query. A suspicious request, a server error, and a confirmed unauthorized result are different levels of evidence.
Reflected XSS: request data reaches an unsafe browser context
In reflected XSS, untrusted request content is returned in a response and reaches a context where the browser can interpret attacker-controlled active content. A search label or error page is a common place to inspect. A crafted link is one possible delivery route; the weakness is not inherently limited to one person, because similar requests can reach many recipients. Without server persistence, a later clean request need not contain that value. Showing angle brackets as literal text is not the same as executing a script.
Stored XSS: saved content remains untrusted when displayed
Stored XSS can arise when a comment or other untrusted value is retained and later rendered into an unsafe browser context. The database storing a string does not execute JavaScript; the browser interpretation boundary matters. Exposure depends on who opens the affected view and how it renders the value, not automatically every visitor to the entire site. A moderation dashboard may be affected even when the public view is protected. Reflected and stored describe delivery and persistence; client-side DOM handling is another dimension to review.
Protect the output context rather than applying one universal filter
For ordinary display text, use a framework or API that creates text instead of interpreting markup. Context-appropriate output encoding is needed when inserting values into syntax-bearing templates; HTML, JavaScript, attributes, and URLs have different rules. If limited user-authored HTML is required, use a maintained sanitizer designed for that purpose. Browser policy and cookie settings add protection but do not repair an unsafe sink. HttpOnly limits script access to a cookie; it does not make all effects of XSS impossible, including actions through an existing session.
Buffer overflow: unsafe writes exceed allocated memory
A buffer overflow can occur when code writes more bytes than a memory region can hold. In an illustrative 24-byte C-style character buffer, a terminating zero byte leaves space for at most 23 one-byte characters. An unchecked copy of 40 such characters plus the terminator needs 41 bytes, exceeding capacity by 17. This may corrupt memory or crash the program; controlled code execution requires further conditions and is not proved by long input alone. Check byte counts and terminators, use bounded operations or memory-safe designs, and keep relevant components updated. A managed-language length error is not automatically a native buffer overflow.
Directory traversal: an input escapes the permitted file location
A file handler that combines an untrusted path with a base directory may reach a parent directory or another unintended location. Normalize and resolve paths using the platform semantics before checking permitted containment and authorization; encoded input, separators, links, and file-open behavior can matter. A raw string-prefix test is insufficient: a sibling name can start with the same letters without being inside the directory. Prefer server-controlled file IDs mapped to approved resources, and constrain what the service can read. Stripping one visible ../ sequence is not a complete design.
5.1.C: Rate the consequence for the particular asset and action
Sensitivity concerns who should read information and the harm of disclosure. Impact also includes incorrect changes, service outages, recovery difficulty, affected people, and operational dependencies. Highly sensitive contact or payment instructions require more care than an already-public exhibition description. Public information can still have high integrity or availability importance, so public does not mean every operation is low risk. Identify the CIA property most directly supported by the scenario and explain other plausible effects separately.
Assess likelihood from exposure and verified conditions
Consider whether the vulnerable path is reachable, what access is required, whether the flaw is actually present, how useful existing controls are, and what testing or activity evidence shows. Internet reachability can increase opportunity, but a scanner label alone does not prove exploit success. Isolation may reduce exposure without removing a weakness. Encryption strength depends on an appropriate algorithm, implementation, configuration, and key management, not an unexplained key-length number alone. State missing evidence instead of inventing certainty.
Use an explicit rubric and retain its assumptions
The classroom matrix below combines impact and likelihood into High, Moderate, or Low. It is an illustrative decision aid, not a universal scoring rule or a legal classification system. A highly damaging, readily reachable exposure ranks above a bounded, less likely inconvenience in this example. Explain why each input rating fits the record. If the data, permissions, or exposure change, reassess the result; a label should summarize the reasoning rather than replace it.
Choose a matching control and verify residual risk
Prioritize the most consequential supported exposures, assign an owner, and select controls that address the identified boundary. Parameterization addresses SQL structure; safe output handling addresses browser interpretation; memory bounds address writes; resource mapping and authorization address file access. Verify positive and negative cases, retain useful evidence, and review remaining access and copies. Recovery can restore damaged data but cannot recall a disclosed copy. After a fix, describe remaining uncertainty and residual risk rather than declaring that one control eliminates every attack.
Follow the input and the permitted action, then test the specific boundary. Keep a suspected attempt separate from the outcome the records confirm.
1. Identify asset and action
Name the data, its sensitivity, the device or service, and whether the request reads, changes, deletes, or executes.
2. Trace the input
Follow the value through request handling, storage, database commands, rendering, memory, or file access.
3. Check authorization
Establish the actor, resource, action, effective role, and server-side permission decision.
4. Choose the boundary control
Match SQL parameters, safe rendering, memory bounds, or approved file mappings to the actual weakness.
5. Verify outcomes
Use permitted and forbidden cases; inspect results and protected logs rather than relying on a success message.
6. Reassess the risk
Combine justified likelihood and impact ratings, assign ownership, and record remaining exposure and uncertainty.
| Finding | Risk to explain | Evidence to verify |
|---|---|---|
| Readable private export on a removable drive | Confidentiality if someone gains access to the readable copy. | Check storage protection, key separation, custody, and actual access evidence. |
| Routine catalog operator retains unnecessary admin access | Compromise may permit wider local changes and access. | Inspect effective privileges and scope, not just the role name. |
| Former volunteer retains edit access to an internal plan | Unauthorized changes threaten integrity; deletion may affect availability. | Check inherited membership, links, owner approval, and allowed/denied tests. |
| Attack | Boundary that fails | Possible harm and matching control |
|---|---|---|
| SQL injection | Untrusted data changes database command structure. | Extra rows threaten confidentiality; other effects depend on privileges. Bind values and retain authorized scope. |
| Cross-site scripting (XSS) | Untrusted content reaches an active browser interpretation context. | Can expose data or misuse a session. Use safe text handling or context-specific encoding/sanitization. |
| Buffer overflow | An unsafe write exceeds an allocated memory region. | May corrupt memory, crash, or enable further effects. Enforce byte bounds and use suitable memory-safe designs. |
| Directory traversal | A file operation reaches outside an approved resource location. | Can expose or affect files if the service has access. Use approved mappings, containment, and authorization. |
| Pattern | Where the untrusted value comes from | Who may encounter it | What to verify |
|---|---|---|---|
| Reflected / Type I | A request is echoed into a response without safe output handling. | Recipients whose requests reach the vulnerable view; potentially many people. | Trace request → response → browser sink and distinguish text, markup, and active execution. |
| Stored / Type II | Saved content is later included in a response or client-rendered view. | Readers of the affected view, possibly moderators or a particular role. | Trace write → storage → affected read path → browser sink; stored does not mean trusted. |
| Input characters | Required bytes including terminator | Bytes beyond capacity | Fits this buffer? |
|---|---|---|---|
| 12 | 13 | 0 | Yes |
| 23 | 24 | 0 | Yes |
| 24 | 25 | 1 | No |
| 40 | 41 | 17 | No |
| Impact | High likelihood | Moderate likelihood | Low likelihood |
|---|---|---|---|
| High impact | High | High | Moderate |
| Moderate impact | High | Moderate | Low |
| Low impact | Moderate | Low | Low |
| Case | Impact evidence | Likelihood evidence | Illustrative rating |
|---|---|---|---|
| A: private payment instructions exposed | High: unauthorized disclosure or alteration could cause substantial harm. | High: a public endpoint is verified to return the restricted record without permission. | High: contain the access, preserve evidence, and verify the fix. |
| B: internal draft plan with stale editor access | Moderate: limited internal disruption; version history is tested. | Moderate: a former volunteer still has effective access; no completed misuse shown. | Moderate: remove stale access and verify inheritance and shared links. |
| C: intended public poster read | Low for confidentiality in this scope: the same poster is already public. | Low for unauthorized disclosure: testing returns only that approved public resource. | Low for this read operation; review edit/delete and service availability separately. |
An access finding is not yet proof that a private file was read
Fictional gallery access review
Asset: removable drive containing a readable private vendor estimate.
Storage: no at-rest encryption recorded; custody gap under review.
Workstation role: routine operator also has unnecessary local admin rights.
Shared plan: former volunteer retains editor access through a group.
Audit result: no completed unauthorized read or edit established yet.
AI draft: "Encryption alone will fix every permission and prove no leak occurred."The readable copy, unnecessary privilege, and stale editor access are separate weaknesses. Appropriate encryption with protected keys can reduce exposure of a locked lost drive, but does not remove the former volunteer’s application access or repair a file already copied in readable form. Review effective roles, inherited membership, storage/copy locations, and available access evidence. Restrict the specific exposures and verify required work. The audit does not establish either a completed disclosure or certainty that no access occurred.
SQL fixture: a value changes query logic when concatenated
Fictional in-memory catalog; no real database connection
item_id | title | tag | public
11 | River bowl | ceramic | 1
12 | Unreleased commission | clay | 0
13 | Woven panel | textile | 1
Untrusted tag: ceramic' OR 'p'='p
Unsafe constructed statement:
SELECT item_id, title FROM exhibits
WHERE public = 1 AND tag = 'ceramic' OR 'p'='p'
ORDER BY item_id;
Returned IDs in this fixture: 11, 12, 13
Bound-parameter statement:
SELECT item_id, title FROM exhibits
WHERE public = 1 AND tag = ?
ORDER BY item_id;
Bound value: the entire untrusted tag above
Returned IDs in this fixture: none
Normal bound tag ceramic: returns ID 11The unsafe expression has an OR condition that is true for every row, so the intended public filter no longer limits this fixture’s result. Item 12 is private: returning it demonstrates a confidentiality failure in the example. Binding the same candidate treats it as a literal tag with no match; it does not execute the added condition. The fixed public filter must remain server-controlled. This read example does not prove a database write, deletion, or authentication bypass. Parameterization must accompany authorization and appropriately limited database privileges.
A harmless markup marker distinguishes parsing from literal text
Fictional rendering review; marker contains no script or event handler
Candidate label: <em data-demo="gallery">Preview label</em>
Reflected path: request label -> response -> display element
Stored path: saved comment -> moderator view -> display element
Unsafe display operation: ordinaryElement.innerHTML = candidate
Observed marker result: an em element appears.
Text display operation: ordinaryElement.textContent = candidate
Observed marker result: literal angle brackets; no em child.
No JavaScript execution or cookie access is demonstrated by this marker.The marker shows whether a plain-text field is interpreted as markup, not a completed script attack. Investigate all affected sinks and their contexts. Reflected and stored paths differ in persistence, but both need safe output handling; a value read from a database is still untrusted. For a normal text element, a text assignment preserves the literal value. If limited authored HTML is a requirement, use suitable sanitization instead. Browser policy and HttpOnly cookies add limits but do not replace correcting the interpretation boundary.
Buffer arithmetic without executing an unsafe copy
Illustrative native import field
Allocated character buffer: 24 bytes
Encoding assumption: one byte per input character
Required terminator: 1 byte
Submitted input: 40 characters
Required storage: 40 + 1 = 41 bytes
Excess if copied without checking: 41 - 24 = 17 bytes
Maximum fitting input under these assumptions: 23 characters
No unchecked native copy is executed in this exercise.The unsafe model would exceed capacity by 17 bytes, including the terminator requirement. It does not establish which adjacent object would be affected or prove code execution. A safe implementation must reject or safely handle input according to its byte-capacity contract. Multibyte input changes the relationship between character count and byte count, and runtime safeguards may reject a copy before corruption. Review the actual language, library, and compiled component rather than labeling every long form submission a successful overflow.
A parent path and a misleading sibling both escape the intended directory
Fictional file handler
Approved base: /srv/lumen/public-downloads
Normal relative value: poster-2027.pdf
Normalized result: /srv/lumen/public-downloads/poster-2027.pdf
Untrusted relative value: ../private/board-plan.txt
Normalized result: /srv/lumen/private/board-plan.txt
Containment result: outside approved base -> DENY
Sibling candidate: /srv/lumen/public-downloads-archive/old-plan.txt
It starts with the base letters but is not a child of the base directory.
Approved mapping: poster-2027 -> approved public poster resourceThe parent segment resolves outside the approved directory; the sibling example defeats a naive raw-prefix check as well. Whether a vulnerable handler could return a file depends on existence, service privileges, and other controls. Prefer a server-owned resource mapping and authorize the requested action. Where paths must be accepted, use a platform-appropriate containment design that accounts for decoding, links, and file-open behavior; lexical normalization alone is not a complete security boundary. Test legitimate downloads and forbidden resources.
Read the outcome field before labeling every request a successful attack
Separate fictional lab observations; 2026-11-04 UTC
10:00:04 Suspicious query candidate rejected; status 403; returned rows 0
10:01:10 Isolated catalog test returns IDs 11,12,13 to public role
10:03:00 File path resolves outside allowed base; status 403; returned bytes 0
10:06:00 Long import field rejected by byte-length check; worker remains healthy
10:08:00 Comment marker creates em element in moderator view; no script test
AI draft: "All five records prove successful compromise of the database and server."The isolated catalog result confirms an unauthorized private row in that test. The denied query, denied file response, and rejected input do not demonstrate successful exploitation through those tested paths. The markup marker shows an interpretation concern, not confirmed JavaScript execution. None of these records establishes destructive database changes or server takeover. Correlate the relevant component, actor, resource, result, and scope, and keep test evidence separate from claims about live production activity.
Vocabulary in context
- Plaintext
- Readable data not protected as ciphertext; a protected primary copy does not automatically protect every export.
- Least privilege
- Access limited to the actions and resources needed for the role, with effective permissions verified.
- Input validation
- Checking that a supplied value meets an expected contract; it does not replace authorization or safe interpretation.
- Parameter binding
- Supplying a value separately from fixed database command syntax so it remains data in a parameter position.
- SQL injection
- A flaw that lets untrusted input alter the logic or structure of a database command.
- Cross-site scripting
- Untrusted content reaching a browser context that permits unintended active behavior.
- Reflected XSS
- An XSS delivery pattern in which request content is returned into an unsafe browser context without needing server persistence.
- Stored XSS
- An XSS delivery pattern in which retained untrusted content later reaches an unsafe rendering path.
- Buffer overflow
- An out-of-bounds memory write caused by exceeding a buffer’s allocated capacity; consequences depend on context.
- Directory traversal
- Manipulation of a file operation to reach resources outside its intended location or scope.
- Likelihood
- The assessed chance of the harmful event under the stated exposure, conditions, controls, and evidence.
- Residual risk
- Risk remaining after controls, including unresolved exposure, operational limits, and uncertainty.
Quick checks
Form your answer, then open the question to compare your reasoning.
1. Why might operating-system permissions be insufficient for a lost unencrypted removable drive?
Someone with sufficient storage access may read the files outside the original operating system’s normal permission enforcement. Appropriate encryption with protected keys helps reduce that exposure; assess the actual access and copies.
2. Does encrypting the drive remove a former volunteer’s editor access?
No. Storage protection and application authorization address different boundaries. Review effective groups, inherited roles, and sharing links, then verify the intended allowed and denied actions.
3. What makes unnecessary administrator access a vulnerability even before misuse is confirmed?
It gives a compromised routine account wider privileges than required. The increased potential consequence is a finding; it does not itself prove that an adversary used those rights.
4. A file is readable by unauthorized people but cannot be changed. Which CIA property is directly at risk?
Confidentiality. Read-only access can expose information even when editing is blocked. Separate possible editing, deletion, and service-disruption effects from the supported read exposure.
5. Does protected network transport prove a downloaded copy is protected at rest?
No. The receiving device may save a readable copy. Trace downloads, temporary files, logs, backups, and key access as well as the transfer.
6. Why can a browser’s input check be bypassed?
A client can submit a request outside that interface. The server must enforce the input contract and authorize the resource and action independently.
7. Which component interprets SQL injection, and which interprets XSS?
SQL injection changes a database command. XSS reaches a browser interpretation context. Their different boundaries require different primary controls.
8. Why does the unsafe catalog statement return the private row?
The added OR condition is true for every row in the fixture, so the original public-and-tag filter no longer constrains the result. The private row’s disclosure is the demonstrated confidentiality failure.
9. What does binding the full untrusted catalog tag change?
The candidate becomes a literal tag value rather than part of the SQL expression. No row has that tag, so this fixture returns none; normal bound ceramic returns public item 11.
10. Can a parameter marker safely choose any table or sort expression supplied by the requester?
Generally no. Parameters bind values, not arbitrary SQL structure. Map allowed structural choices to server-owned identifiers or expressions, and retain authorization.
11. Does a successful read-only injection prove that the database was modified?
No. Modification requires an applicable operation and sufficient privileges, with evidence of its result. Restricted write privileges limit damage but do not repair unsafe query construction.
12. Can reflected XSS affect more than one recipient?
Yes. Similar crafted requests can reach many people. Reflected describes the delivery path and lack of required server persistence, not a fixed one-person limit.
13. Must stored XSS affect every visitor to a website?
No. Exposure depends on the affected view, reader roles, rendering context, and defenses. An unsafe moderator view may be vulnerable even when a public view is protected.
14. Does the database execute JavaScript merely because it stores a comment?
No. For XSS, trace how untrusted content later reaches a browser sink that interprets it unsafely. Storage alone is not browser execution.
15. What does the harmless em marker prove when an em element appears?
It demonstrates markup parsing at that tested sink. It does not prove JavaScript execution, cookie access, or complete session compromise.
16. For a plain-text label in an ordinary element, why prefer textContent to raw innerHTML?
A text assignment treats the candidate as literal text rather than parsing its markup. Other contexts and deliberately authored HTML need suitable context-specific controls.
17. Does an HttpOnly session cookie make XSS harmless?
No. It restricts direct script access to that cookie, but does not repair script execution or all possible actions through an existing session.
18. How many bytes does the 40-character buffer example require, and how far does it exceed capacity?
Under the stated one-byte-character and one-byte-terminator assumptions, it needs 41 bytes. That exceeds the 24-byte buffer by 17 bytes; at most 23 input characters fit.
19. Does a very long request establish a successful buffer overflow?
No. The component may reject the input or use memory-safe storage. Confirm a vulnerable native write and actual outcomes before claiming corruption or code execution.
20. Where does the example ../private/board-plan.txt resolve?
From /srv/lumen/public-downloads, lexical normalization yields /srv/lumen/private/board-plan.txt, outside the approved base. A safe design denies it and accounts for more than lexical spelling.
21. Why is a raw path-prefix check insufficient for containment?
A sibling such as public-downloads-archive can share the same starting letters without being inside public-downloads. Decoding, links, platform semantics, and the actual file-open operation also matter.
22. A valid record ID returns a forbidden record through a correctly parameterized query. What is missing?
Per-resource authorization. Valid formatting and safe query parameters do not establish that the current actor may read that record.
23. How does the illustrative matrix rate High impact with Low likelihood?
Moderate. Explain the stated assumptions rather than applying that illustrative matrix as a universal rule. Reassess if reachability, controls, or consequences change.
24. Can an intended public poster read be low risk while public editing is more serious?
Yes. The read may disclose nothing beyond intended public information, while unauthorized editing or deletion can affect integrity or availability. Rate the action and asset context, then verify residual risk after controls.
Worked example
A user can request another student record by changing an identifier in the application request. Identify the missing control.
Evidence
Authenticated user: student A
Requested record owner: student B
Server result: record returned
Ownership check: absentThe server must authorize access to each requested record, not merely verify that someone logged in. Restrict the query or record operation to the current permitted scope, log relevant access safely, and verify allowed and denied cases. Hiding an identifier in the interface is not a server-side permission check.
Exercises
Exercise 1
Why is client-side input validation insufficient as the only protection for an application endpoint?
Show solution
A client can send requests outside the expected interface. The server must validate input and enforce authorization for every relevant operation.
Exercise 2
After correcting the record-ownership check, give one positive and one negative regression test.
Show solution
Positive: student A can read their own permitted record. Negative: the same authenticated student cannot read student B records by changing an identifier. Verify the denial does not expose sensitive details.
