Intro YAML (“YAML Ain’t Markup Language”) is a human‑readable data‑serialization format used widely for configuration files and data exchange. YAML favors readability via indentation to represent hierarchy and supports mappings (key–value), sequences (lists), and scalars (strings, numbers, booleans). Why AppSec cares YAML powers critical automation and infrastructure – Kubernetes manifests, Docker Compose, GitHub Actions, Helm charts, Ansible, and AWS CloudFormation – so securing YAML is essential to resilient CI/CD and cloud‑native pipelines. YAML basics: structure & syntax Mapping (object): key: value Sequence (list): - item (leading dashes) Scalar: strings, numbers, booleans, nulls Indentation: spaces only; indentation defines nesting Multi‑document: --- (start), ... (optional end) Anchors & aliases: reuse blocks with &name and *name YAML Syntax Example # A simple service definition service: &svc name: payments port: 8080 env: - key: LOG_LEVEL value: "info" - key: FEATURE_X value: "enabled" deployments: - <<: *svc name: payments-staging port: 8081 - <<: *svc name: payments-prod port: 80 Tip: Quote strings like “on”, “off”, “yes”, “no” when you intend them as strings – unquoted they may be parsed as booleans. Where you’ll see YAML in modern stacks Kubernetes manifests for Pods, Deployments, RBAC, etc. Docker Compose service definitions (docker-compose.yml). GitHub Actions workflows (.github/workflows/*.yml). Helm charts (Kubernetes packaging). Ansible playbooks and inventories. AWS CloudFormation templates. Scan YAML as code: Bring YAML into your AppSec program with IaC Security, KICS (open‑source), and Container Security so misconfigurations never make it to production. YAML security risks & best practices Common risks Unsafe deserialization: parsing untrusted YAML using unsafe loaders can enable code execution or DoS in some libraries. Secrets in plain text: credentials, tokens, or keys embedded in YAML or git history. Misconfigurations: overly permissive RBAC, insecure defaults, missing validations. Injection/overrides: unintended variable substitution or anchor/alias misuse. How to secure YAML in CI/CD Use safe parsers: prefer “safe” constructors/loaders for untrusted content. Keep secrets out of YAML: store in a secret manager; add pre‑commit & pipeline checks with Secrets Detection. Lint & validate: enforce schemas/policies (e.g., Kubernetes) in CI. Scan as part of DevSecOps: add IaC Security or KICS; correlate with SCA and SAST. Least privilege: lock down actions, runners, service accounts, cluster roles. Repository hygiene: enforce branch protections and monitor with Repository Health. YAML vs. JSON Comparison Table Aspect YAML JSON Readability Human‑friendly; supports comments Concise; no comments by spec Structure Indentation defines hierarchy Braces/brackets define hierarchy Tooling Great for configs & templating Ubiquitous for APIs & services Interoperability Can embed JSON Strict grammar; widely supported Security Beware unsafe loaders; lint & scan Simpler parser surface FAQ Is a YAML file the same as a YML file? Yes. .yaml and .yml are both common extensions. Where should I start to secure YAML at scale? Enforce linting and schema validation in CI, scan with IaC Security or KICS, catch secrets with Secrets Detection, and correlate risk with SCA and SAST. Does YAML replace JSON? No – choose the format that fits your tooling and workflows. What are some YAML “gotchas”? Spaces (not tabs), accidental booleans (on/off/yes/no), and anchors/aliases misuse. Add linters and tests.