Logo Build Yaml Misconfiguration

Build Yaml Misconfiguration

Tổ chức
RedHatProductSecurity
build-yaml-misconfiguration

Apply when reviewing or writing GitLab CI (.gitlab-ci.yml), Tekton pipeline/task YAML, or Containerfiles/Dockerfiles used in CI builds. Detects common misconfigurations that expose secrets, weaken isolation, skip security gates, grant excessive privileges, or produce insecure container images.

Add to TypingMind

Tổng quan

Nhà phát hànhRedHatProductSecurity
Kho mãprodsec-skills
Tên kỹ năngbuild-yaml-misconfiguration
Sao
56
Bản fork
9
Tệp đi kèm
Chỉ có hướng dẫn
Giấy phépApache-2.0
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • Hướng dẫn có đủ mọi thứ cần thiết

    Mọi thứ mô hình cần đều nằm trong hướng dẫn — không có tệp bổ sung cần đồng bộ.

  • Mã nguồn mở

    Được RedHatProductSecurity công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Build Yaml Misconfiguration trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/RedHatProductSecurity/prodsec-skills/tree/main/module/skills/build-yaml-misconfiguration
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/RedHatProductSecurity/prodsec-skills.git /tmp/prodsec-skills
mkdir -p .claude/skills
cp -r /tmp/prodsec-skills/module/skills/build-yaml-misconfiguration .claude/skills/build-yaml-misconfiguration
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Build Yaml Misconfiguration trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Build Yaml Misconfiguration ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Build Yaml Misconfiguration với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Build YAML Misconfiguration

Detect and prevent security misconfigurations in GitLab CI and Tekton pipeline definitions. Misconfigured build YAML is a common source of secret leakage, privilege escalation, and supply chain compromise.

GitLab CI (.gitlab-ci.yml)

Secret Exposure

  • Never hardcode secrets in .gitlab-ci.yml, variables:, or script: blocks. Use CI/CD protected variables or an external vault.
  • Mask and protect variables: set masked: true and protected: true on sensitive CI/CD variables. Masked variables are redacted from job logs.
  • Never echo secrets: avoid echo $SECRET, printenv, env, or set -x in scripts that handle credentials. Debug output is stored in job logs.
  • Restrict variable scope: use protected: true to limit variables to protected branches/tags only. Use environment scoping to restrict which jobs see which secrets.
  • Artifacts and caches: never include files containing secrets (.env, credentials, tokens) in artifacts: or cache: paths. These are stored and downloadable.
yaml
# BAD -- secret visible in logs and available on all branches
variables:
  DB_PASSWORD: "hunter2"

# GOOD -- use CI/CD protected variable (set in GitLab UI)
# Reference as $DB_PASSWORD in scripts; set masked + protected in settings

Runner and Execution Isolation

  • Never use shared runners for secret-heavy jobs without understanding the trust boundary. Prefer project-specific or group runners for sensitive pipelines.
  • Never use privileged: true in runner config unless absolutely required (e.g., container builds). Privileged runners can escape to the host.
  • Use docker or kubernetes executor over shell executor. Shell executors share the host filesystem and can leak state between jobs.
  • Tag sensitive jobs to run only on hardened, dedicated runners.
yaml
# BAD -- no runner restriction, runs on any available shared runner
deploy-production:
  script:
    - ./deploy.sh

# GOOD -- pinned to a dedicated runner
deploy-production:
  tags:
    - production-deploy
    - privileged-denied
  script:
    - ./deploy.sh

Pipeline Permissions and Trust

  • Protected branches: ensure deploy and release jobs use only: refs: [main] or rules: with branch restrictions. Never allow feature branches to trigger production deploys.
  • Merge request pipelines: use rules: - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' to prevent MR pipelines from accessing protected variables.
  • allow_failure: true: never set this on security scanning jobs (SAST, SCA, secret detection). Failures in security gates must block the pipeline.
  • when: manual: use for production deploys to enforce human approval. Never auto-deploy to production from CI.
yaml
# BAD -- security scan can fail silently
sast:
  allow_failure: true
  script:
    - run-sast-scanner

# GOOD -- security scan blocks pipeline on failure
sast:
  allow_failure: false
  script:
    - run-sast-scanner
  rules:
    - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'

Container Image Builds in CI

  • Never use docker:dind with --privileged without understanding the risk. Prefer Kaniko, Buildah, or Podman for unprivileged image builds.
  • Pin base images by digest, not just tag. Tags are mutable.
  • Do not mount the Docker socket (/var/run/docker.sock) in CI jobs.
  • Scan built images before pushing to registry.
yaml
# BAD -- privileged DinD with mutable tag
build-image:
  image: docker:latest
  services:
    - docker:dind
  variables:
    DOCKER_HOST: tcp://docker:2375
  script:
    - docker build -t myapp .

# GOOD -- unprivileged build with pinned image
build-image:
  image: quay.io/buildah/stable@sha256:<digest>
  script:
    - buildah bud --layers -t myapp .
    - buildah push myapp $CI_REGISTRY_IMAGE:$CI_COMMIT_SHA

Include and Extends Risks

  • Audit remote includes: include: remote: pulls YAML from external URLs. If the remote changes, your pipeline changes. Pin to a specific ref or commit.
  • Audit cross-project includes: include: project: pulls from other GitLab projects. Ensure the source project has proper access controls.
  • Review inherited configuration: extends: and include: can override variables:, script:, and rules: in unexpected ways. Verify the final merged configuration.
yaml
# RISKY -- remote include with no version pinning
include:
  - remote: 'https://example.com/ci-templates/build.yml'

# BETTER -- pinned project include
include:
  - project: 'my-group/ci-templates'
    ref: 'v2.1.0'
    file: '/templates/build.yml'

Tekton Pipelines

Secret Exposure

  • Never inline secrets in Task or Pipeline YAML. Use Kubernetes Secrets referenced via secretKeyRef in env: or mounted as volumes.
  • Never log secrets in steps: avoid echo, printenv, cat on mounted secret files in script: blocks. Tekton step logs are stored and accessible.
  • Workspace binding: when binding secrets as workspaces, ensure the workspace is not shared with untrusted tasks in the same pipeline.
  • Results: never write secrets to Tekton results. Results are stored in the TaskRun/PipelineRun status and visible to anyone with read access.
yaml
# BAD -- secret hardcoded in task
steps:
  - name: deploy
    image: registry.redhat.io/ubi9/ubi-minimal
    script: |
      curl -H "Authorization: Bearer my-secret-token" https://api.example.com

# GOOD -- secret from Kubernetes Secret
steps:
  - name: deploy
    image: registry.redhat.io/ubi9/ubi-minimal
    env:
      - name: API_TOKEN
        valueFrom:
          secretKeyRef:
            name: deploy-creds
            key: token
    script: |
      curl -H "Authorization: Bearer $API_TOKEN" https://api.example.com

Step Image Security

  • Pin images by digest: never use :latest or mutable tags for step images. A compromised tag can inject malicious code into your pipeline.
  • Use trusted registries: prefer registry.redhat.io or your internal registry. Avoid pulling from untrusted public registries in production pipelines.
  • Minimal images: use UBI minimal or distroless images. Avoid full OS images with unnecessary tools that expand the attack surface.
yaml
# BAD -- mutable tag from public registry
steps:
  - name: build
    image: ubuntu:latest

# GOOD -- pinned digest from trusted registry
steps:
  - name: build
    image: registry.redhat.io/ubi9/ubi-minimal@sha256:<digest>

Task and Pipeline Permissions

  • Run steps as non-root: set securityContext.runAsNonRoot: true and runAsUser on steps. Never run build steps as root unless absolutely required.
  • Drop capabilities: set securityContext.capabilities.drop: ["ALL"] on step containers.
  • Do not use privileged: true in step security contexts.
  • Service account scoping: bind the minimum RBAC to the service account running the PipelineRun. Never use the pipeline service account with cluster-admin privileges.
  • Limit workspace access: use readOnly: true on workspace bindings when the task only needs to read.
yaml
# BAD -- running as root with no restrictions
steps:
  - name: build
    image: registry.redhat.io/ubi9/ubi-minimal
    script: |
      make build

# GOOD -- non-root with dropped capabilities
steps:
  - name: build
    image: registry.redhat.io/ubi9/ubi-minimal
    securityContext:
      runAsNonRoot: true
      runAsUser: 1001
      capabilities:
        drop: ["ALL"]
    script: |
      make build

Pipeline Structure Risks

  • Untrusted task references: taskRef with resolver: bundles or resolver: git can pull tasks from external sources. Pin to specific digests or commits.
  • Parameter injection: if pipeline parameters are passed into script: blocks via $(params.*), treat them as untrusted input. Validate and quote them.
  • When expressions: do not use when expressions as security controls. They skip tasks but do not enforce authorization.
  • Finally tasks: use finally: tasks for cleanup (removing credentials, revoking tokens) but never assume they will always run (node failure, timeout).
yaml
# BAD -- unpinned external task bundle
taskRef:
  resolver: bundles
  params:
    - name: bundle
      value: quay.io/someone/my-task:latest

# GOOD -- pinned by digest
taskRef:
  resolver: bundles
  params:
    - name: bundle
      value: quay.io/myorg/my-task@sha256:<digest>

Tekton Chains and Provenance

  • Enable Tekton Chains for automatic signing and attestation of TaskRun/PipelineRun results.
  • Verify signatures on built artifacts before promotion to production registries.
  • Store attestations alongside artifacts for auditability.

Containerfile / Dockerfile Hardening

Container image definitions are typically referenced or inlined in CI YAML. Misconfigurations here produce insecure images that run in production.

Run as Non-Root

  • Never leave USER unset -- the default is root. Always add a USER directive before the final CMD/ENTRYPOINT.
  • Create a dedicated user in the build stage.
dockerfile
# BAD -- runs as root by default
FROM registry.redhat.io/ubi9/ubi-minimal
COPY app /app
CMD ["/app/server"]

# GOOD -- explicit non-root user
FROM registry.redhat.io/ubi9/ubi-minimal
RUN microdnf install -y shadow-utils && \
    useradd -r -u 1001 appuser && \
    microdnf clean all
COPY --chown=appuser:appuser app /app
USER appuser
CMD ["/app/server"]

Secrets in Image Layers

  • Never COPY or ADD secrets (keys, credentials, .env files) into the image. Every layer is extractable.
  • Never use ARG or ENV for secrets -- they are visible in docker inspect and image history.
  • Use BuildKit secret mounts for build-time secrets. They are not persisted in layers.
dockerfile
# BAD -- secret baked into image layer
COPY .env /app/.env
ENV API_KEY=sk-secret-value

# GOOD -- BuildKit secret mount (not persisted in layer)
RUN --mount=type=secret,id=api_key \
    export API_KEY=$(cat /run/secrets/api_key) && \
    ./configure --with-key="$API_KEY"

Base Image Hygiene

  • Pin base images by digest, not mutable tags. :latest or :9 can change without notice.
  • Use trusted registries: prefer registry.redhat.io or your internal registry.
  • Use minimal base images: UBI minimal, micro, or distroless. Fewer packages = smaller attack surface.
  • Remove package managers from the final image when possible.
dockerfile
# BAD -- mutable tag, full OS image
FROM ubuntu:latest

# GOOD -- pinned digest, minimal trusted image
FROM registry.redhat.io/ubi9/ubi-minimal@sha256:<digest>

Multi-Stage Builds

  • Separate build and runtime stages. Build tools, compilers, and test dependencies must not ship in the final image.
  • Copy only the built artifact into the runtime stage.
dockerfile
# GOOD -- multi-stage: build tools stay in builder stage
FROM registry.redhat.io/ubi9/ubi:latest AS builder
RUN dnf install -y gcc make && dnf clean all
COPY . /src
RUN cd /src && make

FROM registry.redhat.io/ubi9/ubi-minimal@sha256:<digest>
COPY --from=builder /src/bin/app /app/server
USER 1001
CMD ["/app/server"]

Build Context Leakage

  • Always use .dockerignore (or .containerignore). Without it, the entire directory (including .git, .env, credentials, IDE configs) is sent to the build daemon.
  • Explicitly exclude sensitive paths.
text
# .dockerignore
.git
.env
*.pem
*.key
credentials/
node_modules/

Unnecessary Capabilities and Ports

  • Do not EXPOSE ports you don't use. While EXPOSE is documentation only, it signals intent and misconfigured orchestrators may open them.
  • Do not install sudo, su, or setuid binaries in the final image.
  • Set HEALTHCHECK so orchestrators can detect unhealthy containers.
dockerfile
# GOOD -- only expose what's needed, add healthcheck
EXPOSE 8080
HEALTHCHECK --interval=30s --timeout=3s \
  CMD curl -f http://localhost:8080/healthz || exit 1

Read-Only and Immutability

  • Design images to run with a read-only root filesystem at runtime. Write only to explicitly mounted volumes or tmpfs.
  • Avoid writing to the container filesystem in CMD/ENTRYPOINT scripts.

Common Containerfile Misconfigurations

MisconfigurationRiskFix
No USER directiveContainer runs as rootAdd USER <non-root> before CMD
COPY .env or COPY *.keySecrets baked into extractable layersUse BuildKit --mount=type=secret
ENV SECRET_KEY=valueSecret visible in docker inspectPass at runtime via orchestrator
FROM image:latestMutable tag; supply chain riskPin by @sha256:<digest>
No .dockerignore.git, credentials sent to build contextCreate .dockerignore with exclusions
Single-stage with build toolsCompilers, test deps ship to productionUse multi-stage builds
RUN chmod 777World-writable files in imageUse specific permissions (chmod 755)
No HEALTHCHECKOrchestrator cannot detect unhealthy stateAdd HEALTHCHECK instruction
sudo or setuid binaries installedPrivilege escalation pathRemove from final image

Common Misconfigurations (Both Platforms)

MisconfigurationRiskFix
Hardcoded secrets in YAMLCredential leakage via repo access or logsUse vault/CI variables/K8s Secrets
allow_failure: true on security jobsSecurity findings silently ignoredSet allow_failure: false
Mutable image tags (:latest)Supply chain compromise via tag poisoningPin by digest
Privileged containers/runnersContainer escape to hostUse unprivileged builds (Buildah/Kaniko)
Unscoped variables/secretsSecrets available to untrusted branches/jobsScope to protected branches/environments
Debug output (set -x, printenv)Secrets printed to job logsRemove debug flags; use masked variables
Unpinned remote includes/task refsExternal changes alter your pipelinePin to version/commit/digest
Missing security scan gatesVulnerable code reaches productionAdd SAST/SCA/image scanning as blocking steps
Auto-deploy to productionNo human review before deployRequire manual approval gate
Shell executor (GitLab)Job-to-job state leakage on shared hostUse Docker/Kubernetes executor
No USER in ContainerfileContainer runs as root in productionAdd non-root USER directive
Secrets in image layersCredentials extractable from imageUse BuildKit secret mounts
No .dockerignoreSensitive files leak into build contextCreate .dockerignore with exclusions
Single-stage buildBuild tools ship to productionUse multi-stage builds

Implementation Checklist

  • No secrets hardcoded in pipeline YAML; all credentials from vault or protected variables
  • Sensitive variables masked and scoped to protected branches/environments
  • Security scan jobs set to block pipeline on failure
  • All step/job images pinned by digest from trusted registries
  • Containers run as non-root with dropped capabilities; no privileged mode
  • Remote includes and task references pinned to specific versions/digests
  • Production deploys require manual approval
  • No debug output (set -x, printenv, env) in jobs that handle secrets
  • Pipeline parameters validated before use in scripts
  • Tekton Chains enabled for provenance and signing (where applicable)
  • Containerfiles set explicit non-root USER before CMD
  • No secrets in image layers, ARG, or ENV; use BuildKit secret mounts
  • .dockerignore / .containerignore excludes .git, .env, keys, credentials
  • Multi-stage builds separate build tools from runtime image
  • Base images from trusted registries, pinned by digest

Test Plan

  • Audit all .gitlab-ci.yml and Tekton Task/Pipeline YAML for patterns in the table above.
  • Verify that protected variables are not accessible from unprotected branches.
  • Confirm security scan jobs block merge on failure.
  • Test that pinned images resolve to the expected digest and are from trusted registries.
  • Review runner/service account RBAC for least privilege.

Câu hỏi thường gặp

Kỹ năng AI Build Yaml Misconfiguration làm được gì?

Apply when reviewing or writing GitLab CI (.gitlab-ci.yml), Tekton pipeline/task YAML, or Containerfiles/Dockerfiles used in CI builds. Detects common misconfigurations that expose secrets, weaken isolation, skip security gates, grant excessive privileges, or produce insecure container images.

Vì sao nên dùng Build Yaml Misconfiguration trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Build Yaml Misconfiguration là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Build Yaml Misconfiguration trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/RedHatProductSecurity/prodsec-skills/tree/main/module/skills/build-yaml-misconfiguration. TypingMind đọc tệp SKILL.md rồi cài đặt kỹ năng để bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Build Yaml Misconfiguration?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Build Yaml Misconfiguration với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Build Yaml Misconfiguration với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Build Yaml Misconfiguration có miễn phí không?

Có. Kỹ năng này được RedHatProductSecurity phát hành trên GitHub theo giấy phép Apache-2.0. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇