Skip to content

fix(ci): exclude auth caches from ci.cache (defensive hardening) - #2705

Merged
Andriy Knysh (aknysh) merged 7 commits into
mainfrom
osterman/exclude-auth-cache-default
Jul 9, 2026
Merged

Andriy Knysh (aknysh) merged 7 commits into
mainfrom
osterman/exclude-auth-cache-default

Conversation

@osterman

@osterman Erik Osterman (Cloud Posse) (osterman) commented Jul 8, 2026 •

Copy link
Copy Markdown
Member

what

  • ci.cache (the CI build cache) now excludes aws-sso, azure-device-code, aws-webflow, and auth — the subdirectories under ~/.cache/atmos where Atmos persists session credentials — unconditionally, with no opt-out, regardless of ci.cache.paths.
  • Applies in both Atmos's own cache backend (pkg/ci/cache/archive.go) and the atmos ci cache paths output used with the native actions/cache GitHub Action (rendered as !-prefixed glob exclusions, working around a known actions/toolkit glob-depth limitation).
  • Drift-guard tests in each owning auth package assert their subdir constants stay in sync with the exclusion list, so a rename can't silently reopen the gap.
  • Docs (website/docs/cli/configuration/ci/cache.mdx, docs/prd/native-ci/framework/ci-cache.md) and an internal fix note (docs/fixes/) are included.

why

  • ci.cache's default behavior (cache the entire XDG cache root when ci.cache.paths is unset) meant Atmos's own auth session material (AWS SSO tokens/refresh token/client secret, Azure device-code tokens, Atmos's webflow refresh token) sat in the same directory tree that gets archived by default.
  • This is purely defensive hardening — ci.cache was never demonstrated to be exploitable or vulnerable in CI. A repo's GitHub Actions cache is already scoped to that repo, and everything involved is short-lived, rotating session material. This change just makes it structurally impossible for these directories to end up in a cache archive, rather than relying on ci.cache.paths conventions.
  • OIDC-based auth (GitHub/GCP/Azure) was confirmed unaffected either way — those flows never write credentials to disk.

references

  • docs/prd/native-ci/framework/ci-cache.md#default-excluded-auth-paths

ci.cache archived the entire ~/.cache/atmos root when ci.cache.paths was
unset, which meant AWS SSO tokens, Azure device-code tokens, and Atmos's
webflow refresh tokens could get bundled into the same CI cache archive as
the toolchain. Exclude those subdirectories unconditionally in both the
Atmos-managed backend and the actions/cache passthrough, with a new
ci.cache.allow_unsafe_auth_cache escape hatch for anyone who needs the old
behavior.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@atmos-pro

atmos-pro Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@osterman Erik Osterman (Cloud Posse) (osterman) added the minor New features that do not break anything label Jul 8, 2026
@github-actions github-actions Bot added the size/m Medium size PR label Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Files

None

@coderabbitai

coderabbitai Bot commented Jul 8, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Adds a canonical cachepaths package defining auth/session cache subdirectory names, exposes DefaultExcludedPaths() in pkg/ci/cache, wires unconditional exclusion into archive skip logic, extends atmos ci cache paths output with negated glob/env/JSON/YAML excludes, aliases existing auth constants to the shared package, and updates documentation.

Changes

Auth cache exclusion feature

Layer / File(s) Summary
Canonical cache subdir constants
pkg/auth/cachepaths/cachepaths.go, pkg/auth/cachepaths/cachepaths_test.go, pkg/ci/cache/exclusions.go, pkg/ci/cache/exclusions_test.go
New cachepaths package defines AWS SSO, Azure device-code, AWS webflow, and provisioning subdir constants and All(); DefaultExcludedPaths() wraps All() with perf.Track; tests verify contents, order, and defensive copy behavior.
Archive skip decision logic
pkg/ci/cache/archive.go, pkg/ci/cache/archive_test.go
archiveRoot/archiver now carry excludes; archiveSkipDecision unconditionally prunes the state dir and default-excluded paths via isUnderPrefix/isStateDir/pruneAction before include checks; tests confirm pruning even when a path is explicitly included.
Cache paths output with excludes
cmd/ci/cache/paths.go, cmd/ci/cache/paths_test.go
cachePathsData gains ExcludePaths; cacheResolvedExcludes resolves default excludes against cfg.Root; githubGlobLines emits dir/** and !dir/** lines; emitCachePaths emits excludes for github, env (ATMOS_CI_CACHE_EXCLUDE_PATHS), json, and yaml formats; tests cover all formats and a new stream-capture harness.
Auth package constant aliasing
pkg/auth/identities/aws/webflow.go, pkg/auth/providers/aws/sso_cache.go, pkg/auth/providers/azure/device_code_cache.go, pkg/auth/provisioning/writer.go
AWS webflow, SSO, Azure device-code, and provisioning writer cache subdir constants now alias cachepaths constants instead of hardcoded strings.
Documentation updates
docs/fixes/2026-07-08-ci-cache-excludes-auth-caches.md, docs/prd/native-ci/framework/ci-cache.md, pkg/schema/schema.go, website/docs/cli/configuration/ci/cache.mdx
Documents the unconditional auth-cache exclusions, the new ATMOS_CI_CACHE_EXCLUDE_PATHS variable, actions/cache glob limitations, and drift-guard test coverage.

Estimated code review effort: 3 (Moderate) | ~30 minutes

Sequence Diagram(s)

sequenceDiagram
  participant archiveRoot
  participant archiveSkipDecision
  participant isUnderPrefix

  archiveRoot->>archiveSkipDecision: evaluate entry (includes, excludes)
  archiveSkipDecision->>isUnderPrefix: check defaultExcludedPaths
  isUnderPrefix-->>archiveSkipDecision: match / no match
  archiveSkipDecision-->>archiveRoot: prune (SkipDir) or include
Loading

Possibly related PRs

  • cloudposse/atmos#2579: Extends the same atmos ci cache paths implementation this PR builds default exclude-path handling and GitHub glob negation on top of.

Suggested labels: patch

Suggested reviewers: aknysh

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 61.54% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: excluding auth caches from ci.cache as a hardening fix.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch osterman/exclude-auth-cache-default

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 8, 2026 •

Copy link
Copy Markdown

Resource Changes Found for bucket in test

Atmos CI

create

Plan: 4 to add, 0 to change, 0 to destroy.
To reproduce this locally, run:

atmos terraform plan bucket -s test

Create

+ aws_s3_bucket.checkov_target
+ aws_s3_bucket.this
+ aws_s3_bucket.trivy_target
+ aws_s3_bucket_public_access_block.trivy_target
Terraform Plan Summary
  # aws_s3_bucket.checkov_target will be created
  + resource "aws_s3_bucket" "checkov_target" {
      + acceleration_status         = (known after apply)
      + acl                         = (known after apply)
      + arn                         = (known after apply)
      + bucket                      = "atmos-native-ci-e2e-checkov-test"
      + bucket_domain_name          = (known after apply)
      + bucket_prefix               = (known after apply)
      + bucket_regional_domain_name = (known after apply)
      + force_destroy               = false
      + hosted_zone_id              = (known after apply)
      + id                          = (known after apply)
      + object_lock_enabled         = (known after apply)
      + policy                      = (known after apply)
      + region                      = (known after apply)
      + request_payer               = (known after apply)
      + tags_all                    = (known after apply)
      + website_domain              = (known after apply)
      + website_endpoint            = (known after apply)

      + cors_rule (known after apply)

      + grant (known after apply)

      + lifecycle_rule (known after apply)

      + logging (known after apply)

      + object_lock_configuration (known after apply)

      + replication_configuration (known after apply)

      + server_side_encryption_configuration (known after apply)

      + versioning (known after apply)

      + website (known after apply)
    }

  # aws_s3_bucket.this will be created
  + resource "aws_s3_bucket" "this" {
      + acceleration_status         = (known after apply)
      + acl                         = (known after apply)
      + arn                         = (known after apply)
      + bucket                      = "atmos-native-ci-e2e-test"
      + bucket_domain_name          = (known after apply)
      + bucket_prefix               = (known after apply)
      + bucket_regional_domain_name = (known after apply)
      + force_destroy               = false
      + hosted_zone_id              = (known after apply)
      + id                          = (known after apply)
      + object_lock_enabled         = (known after apply)
      + policy                      = (known after apply)
      + region                      = (known after apply)
      + request_payer               = (known after apply)
      + tags                        = {
          + "AtmosFixture" = "native-ci-e2e"
          + "Stage"        = "test"
        }
      + tags_all                    = {
          + "AtmosFixture" = "native-ci-e2e"
          + "Stage"        = "test"
        }
      + website_domain              = (known after apply)
      + website_endpoint            = (known after apply)

      + cors_rule (known after apply)

      + grant (known after apply)

      + lifecycle_rule (known after apply)

      + logging (known after apply)

      + object_lock_configuration (known after apply)

      + replication_configuration (known after apply)

      + server_side_encryption_configuration (known after apply)

      + versioning (known after apply)

      + website (known after apply)
    }

  # aws_s3_bucket.trivy_target will be created
  + resource "aws_s3_bucket" "trivy_target" {
      + acceleration_status         = (known after apply)
      + acl                         = (known after apply)
      + arn                         = (known after apply)
      + bucket                      = "atmos-native-ci-e2e-trivy-test"
      + bucket_domain_name          = (known after apply)
      + bucket_prefix               = (known after apply)
      + bucket_regional_domain_name = (known after apply)
      + force_destroy               = false
      + hosted_zone_id              = (known after apply)
      + id                          = (known after apply)
      + object_lock_enabled         = (known after apply)
      + policy                      = (known after apply)
      + region                      = (known after apply)
      + request_payer               = (known after apply)
      + tags_all                    = (known after apply)
      + website_domain              = (known after apply)
      + website_endpoint            = (known after apply)

      + cors_rule (known after apply)

      + grant (known after apply)

      + lifecycle_rule (known after apply)

      + logging (known after apply)

      + object_lock_configuration (known after apply)

      + replication_configuration (known after apply)

      + server_side_encryption_configuration (known after apply)

      + versioning (known after apply)

      + website (known after apply)
    }

  # aws_s3_bucket_public_access_block.trivy_target will be created
  + resource "aws_s3_bucket_public_access_block" "trivy_target" {
      + block_public_acls       = true
      + block_public_policy     = true
      + bucket                  = (known after apply)
      + id                      = (known after apply)
      + ignore_public_acls      = true
      + restrict_public_buckets = true
    }

Plan: 4 to add, 0 to change, 0 to destroy.

Changes to Outputs:
  + bucket_name = "atmos-native-ci-e2e-test"

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 8, 2026
Remove ci.cache.allow_unsafe_auth_cache entirely so the auth-cache
exclusion has no escape hatch, and reword the docs/PRD/fix notes to
describe this as defensive hardening rather than a vulnerability fix --
ci.cache was never actually exploitable in CI, this just makes the
exclusion unconditional and permanent. Also drop the changelog blog post
and roadmap entry, which don't belong on a patch-level hardening change.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@osterman Erik Osterman (Cloud Posse) (osterman) added patch A minor, backward compatible change and removed minor New features that do not break anything labels Jul 8, 2026
@osterman Erik Osterman (Cloud Posse) (osterman) changed the title fix(ci): exclude auth session caches from ci.cache by default fix(ci): exclude auth caches from ci.cache (defensive hardening) Jul 8, 2026
@github-actions

github-actions Bot commented Jul 8, 2026

Copy link
Copy Markdown

Warning

Release Documentation Required

This PR is labeled minor or major and requires documentation updates:

  • Changelog entry - Add a blog post in website/blog/YYYY-MM-DD-feature-name.mdx
  • Roadmap update - Update website/src/data/roadmap.js with the new milestone

Alternatively: If this change doesn't require release documentation, remove the minor or major label.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/fixes/2026-07-08-ci-cache-excludes-auth-caches.md`:
- Around line 1-3: The document title currently says “by default,” but the
described behavior is unconditional, so update the heading in the markdown doc
to match the always-on exclusion behavior. Adjust the title text in the docs
entry for the CI cache/auth cache change so it clearly reflects that Atmos’s
auth session caches are excluded without opt-out, keeping the body consistent
with the heading.

In `@docs/prd/native-ci/framework/ci-cache.md`:
- Around line 181-185: The wording in the ci.cache.paths section overstates the
excluded data as only short-lived session material. Update the prose around the
carve-out to describe it as protecting authentication material more broadly, and
align the description with the later aws-sso entry by avoiding any claim that
every excluded item is ephemeral; keep the change localized to the explanatory
sentence in the ci-cache documentation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: c7c2ed4d-82dc-4fac-8f0c-221b72c18be8

📥 Commits

Reviewing files that changed from the base of the PR and between 5a213d8 and 3f250bf.

📒 Files selected for processing (9)
  • cmd/ci/cache/paths.go
  • cmd/ci/cache/paths_test.go
  • docs/fixes/2026-07-08-ci-cache-excludes-auth-caches.md
  • docs/prd/native-ci/framework/ci-cache.md
  • pkg/ci/cache/archive.go
  • pkg/ci/cache/archive_test.go
  • pkg/ci/cache/exclusions.go
  • pkg/schema/schema.go
  • website/docs/cli/configuration/ci/cache.mdx
💤 Files with no reviewable changes (1)
  • cmd/ci/cache/paths_test.go
✅ Files skipped from review due to trivial changes (2)
  • pkg/schema/schema.go
  • website/docs/cli/configuration/ci/cache.mdx
🚧 Files skipped from review as they are similar to previous changes (1)
  • pkg/ci/cache/exclusions.go

Title reflects the unconditional (no opt-out) behavior rather than "by
default", and the excluded-auth-material description no longer implies
everything excluded is short-lived (aws-sso includes an OAuth client
secret).

Co-Authored-By: Claude Sonnet 5 <[email protected]>
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 8, 2026
TestRunCachePaths_JSON_ExcludePathsField and
TestRunCachePaths_YAML_ExcludePathsField wrapped the expected substring in
filepath.ToSlash, but json/yaml output (unlike the github format) emits raw
OS-native-separator paths with no slash normalization. That happened to
match on Unix but failed on Windows, where the backslashes get escaped in
the JSON text. Assert on the bare subdir name instead, which is
platform-independent.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
coderabbitai[bot]
coderabbitai Bot previously approved these changes Jul 8, 2026
…f package

pkg/ci/cache hardcoded auth's internal cache-subdirectory names as literal
strings with comments pointing at the owning files, synced by hand via four
separate drift-guard tests in the auth packages. Replace that with
pkg/auth/cachepaths, a dependency-free leaf package that is the single
source of truth for these subdirectory names; each owning file
(sso_cache.go, device_code_cache.go, webflow.go, provisioning/writer.go)
now aliases its constant from there instead of duplicating the literal.
pkg/ci/cache only depends on the lightweight cachepaths package, not on the
auth provider packages (which pull in AWS SDK, MSAL, Azure SDK) -- so the
exclusion list can no longer drift, and the drift-guard tests are gone.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@codecov

codecov Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.20%. Comparing base (97846f4) to head (a1e0a78).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2705   +/-   ##
=======================================
  Coverage   81.19%   81.20%           
=======================================
  Files        1630     1632    +2     
  Lines      154206   154238   +32     
=======================================
+ Hits       125205   125246   +41     
+ Misses      22083    22073   -10     
- Partials     6918     6919    +1     
Flag Coverage Δ
unittests 81.20% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
cmd/ci/cache/paths.go 92.00% <100.00%> (+2.16%) ⬆️
pkg/auth/cachepaths/cachepaths.go 100.00% <100.00%> (ø)
pkg/auth/identities/aws/webflow.go 88.46% <ø> (ø)
pkg/auth/providers/aws/sso_cache.go 73.17% <ø> (ø)
pkg/auth/providers/azure/device_code_cache.go 71.89% <ø> (ø)
pkg/auth/provisioning/writer.go 85.50% <ø> (ø)
pkg/ci/cache/archive.go 77.03% <100.00%> (+2.03%) ⬆️
pkg/ci/cache/exclusions.go 100.00% <100.00%> (ø)
pkg/schema/schema.go 86.42% <ø> (ø)

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aknysh
Andriy Knysh (aknysh) merged commit 3cd637f into main Jul 9, 2026
243 of 247 checks passed
@aknysh
Andriy Knysh (aknysh) deleted the osterman/exclude-auth-cache-default branch July 9, 2026 17:36
@atmos-pro

atmos-pro Bot commented Jul 9, 2026 •

Copy link
Copy Markdown
Contributor

Tip

Atmos Pro  

No affected stacks workflow was detected for this pull request.
If this is expected, no action is needed.
Learn More. Ask AI.

@github-actions

Copy link
Copy Markdown

These changes were released in v1.223.0-rc.7.

This branch was successfully deployed

1 active deployment
preview — a1e0a78c Deployed Jul 9, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

patch A minor, backward compatible change size/m Medium size PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants