CAP-PC ENS cheat sheet
CAP-PC ENS · Keep the key ideas within reach.
Web Application Security
CVSS v3.1 base score combines Exploitability (AV, AC, PR, UI) with Impact (C, I, A); scope change alters the PR multiplier and applies a different impact formula.
SQL injection decision rule: if input reaches a query string without parameterization, test boolean, UNION, time-based, and error-based variants in that order; prepared statements with bound parameters are the only structural fix.
XSS taxonomy: reflected (payload in current response), stored (persisted server-side), DOM-based (sink reached client-side, e.g. innerHTML, eval, document.write).
SameSite cookie values: Strict blocks cross-site sends entirely, Lax sends on top-level GET navigations, None requires the Secure attribute.
CSRF defense requires a per-session unpredictable token validated server-side, or SameSite=Lax/Strict plus Origin header checks; a custom header check works only with CORS restrictions.
IDOR is an authorization defect, not authentication: the test is whether swapping an object identifier returns another user's data while the session stays valid.
SSRF filtering must resolve and validate the host after DNS resolution and block link-local 169.254.169.254, loopback, and RFC1918 ranges on every redirect hop.
JWT verification rules: reject alg=none, pin the expected algorithm, verify signature before claims, and treat kid/jku parameters as untrusted input.
Source-Code Analysis
Taint analysis models sources (request parameters, file reads, env vars), sinks (SQL exec, exec, deserialization), and sanitizers; a finding requires a source-to-sink path with no effective sanitizer.
Semgrep rules match on pattern, pattern-either, pattern-not, and metavariables ($X); pattern-not-inside is the standard way to suppress findings already guarded by a sanitizer.
CodeQL queries run against a relational database of the code; sources are modeled with RemoteFlowSource and sinks with DataFlow::Node, joined by TaintTracking::Global.
Sink catalog for Java: Runtime.exec, ProcessBuilder, Statement.execute, ObjectInputStream.readObject, XMLDecoder, ScriptEngine.eval, JNDI lookup.
Sink catalog for Python: eval, exec, os.system, subprocess with shell=True, pickle.loads, yaml.load without SafeLoader, cursor.execute with f-strings.
Secrets detection distinguishes high-entropy strings from placeholders; entropy thresholds near 3.5-4.5 bits per character reduce false positives on test fixtures.
Hardcoded credential triage: confirm the value is live (format-valid, not example), then check git history with git log -S because rotation must cover historical commits.
Dependency review maps a lockfile entry to a CVE via package name, version range, and ecosystem; reachability analysis downgrades findings whose vulnerable function is never called.
Cloud Security Assessment
AWS IMDSv2 requires a PUT to /latest/api/token with a TTL header before GET requests; IMDSv1-only roles are directly reachable from SSRF.
S3 bucket exposure test order: unauthenticated GET on the object URL, then ListBucket on the bucket root, then policy inspection for Principal "*" with s3:GetObject.
IAM privilege escalation primitives include iam:CreatePolicyVersion, iam:AttachUserPolicy, iam:PassRole combined with lambda:CreateFunction or ec2:RunInstances, and sts:AssumeRole on a permissive trust policy.
Azure managed identity tokens are fetched from IMDS at 169.254.169.254/metadata/identity/oauth2/token with Metadata:true; the token audience identifies the target resource.
GCP service account keys and OAuth tokens come from the metadata server at metadata.google.internal with the Metadata-Flavor: Google header.
CloudTrail gaps to check: multi-region trail disabled, log file validation off, S3 data events absent, and CloudWatch Logs delivery removed.
KMS key policy and IAM policy both gate access; a key policy that delegates to the account root is what enables IAM-based grants to work.
Container and workload posture: privileged pods, hostPath mounts, cluster-admin bindings, and public container registries are the highest-signal findings.
Red Team and AI/ML Security
MITRE ATT&CK tactics run in order: Reconnaissance, Resource Development, Initial Access, Execution, Persistence, Privilege Escalation, Defense Evasion, Credential Access, Discovery, Lateral Movement, Collection, C2, Exfiltration, Impact.
C2 profile design separates the beacon (jitter, sleep, user-agent, URI) from the payload; malleable profiles change network indicators without recompiling the implant.
Kerberoasting requests a service ticket for an SPN-bearing account and cracks it offline; detection relies on RC4 ticket requests (4769 with 0x17) at volume.
Prompt injection splits into direct (user input overrides instructions) and indirect (poisoned retrieved document or tool output); indirect is the dominant risk in RAG systems.
LLM defenses to evaluate: input/output filtering, instruction hierarchy, tool allowlists, least-privilege tool scopes, and human approval for state-changing actions.
Model extraction and membership inference are privacy/integrity attacks against the model API; rate limits, output perturbation, and query monitoring are the countermeasures.
Adversarial examples exploit gradient sensitivity; transferability means a perturbation built on a surrogate model often fools the target model.
Data poisoning targets the training pipeline; provenance checks, deduplication, and evaluation-set isolation limit impact on model behavior.