Skip to content

fix(scope): enforce scope violations on introspection failure and unsupported forges (#1622) - #1643

Open
nextlevelshit wants to merge 1 commit into
mainfrom
fix/scope-enforcement-1622
Open

nextlevelshit wants to merge 1 commit into
mainfrom
fix/scope-enforcement-1622

Conversation

@nextlevelshit

Copy link
Copy Markdown
Collaborator

Closes #1622.

Summary

Three token-scope enforcement gaps fixed (from audit-security F1 findings):

  • Finding 1 (HIGH): introspection failure now produces a ScopeViolation blocking execution (was warning+skip)
  • Finding 2 (MEDIUM): nil introspector (unsupported forge) now emits per-scope violations (was warn+return)
  • Finding 3 (MEDIUM): fine-grained PAT error message updated with actionable bypass hint
  • Escape hatch: WAVE_SKIP_SCOPE_CHECK=1 added for fine-grained PATs, unsupported forges, air-gapped/CI environments

Docs updated

  • docs/reference/environment.md — WAVE_SKIP_SCOPE_CHECK row added
  • docs/reference/manifest.md — introspection failure + fine-grained PAT + unsupported forge behavior documented
  • docs/concepts/personas.md — bypass hint added to token scope section

Test plan

  • go test ./internal/scope/... — 10/10 pass
  • golangci-lint run ./internal/scope/... — 0 issues
  • Live test: fine-grained PAT against codeberg.org — should surface violation with hint
  • Live test: WAVE_SKIP_SCOPE_CHECK=1 wave run ... — should bypass and warn

…1622)

- Finding 1 (HIGH): introspection failure → ScopeViolation (was warning+skip)
- Finding 2 (MED): nil introspector (unsupported forge) → per-scope violations (was warn+return)
- Finding 3 (MED): fine-grained PAT hint updated to reference WAVE_SKIP_SCOPE_CHECK=1
- WAVE_SKIP_SCOPE_CHECK=1 bypass added for fine-grained PATs, unsupported forges, air-gapped envs
- Docs: environment.md, manifest.md, concepts/personas.md
@nextlevelshit
nextlevelshit force-pushed the fix/scope-enforcement-1622 branch from ff5c6ab to 15db164 Compare May 2, 2026 13:09

@QuintinBotes QuintinBotes left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Changes requested: 2 comments, the highest important.

if tokenInfo.TokenType == "fine-grained" {
hint = "fine-grained PATs cannot be introspected; recreate as classic PAT or set WAVE_SKIP_SCOPE_CHECK=1 to bypass"
}
result.Violations = append(result.Violations, ScopeViolation{

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

important - GiteaIntrospector always sets tokenInfo.Error after a successful tea whoami, and this line turns that into a ScopeViolation. Every Gitea/Forgejo/Codeberg run with token_scopes fails preflight on a valid token; the hint omits WAVE_SKIP_SCOPE_CHECK.

result := &ValidationResult{}

// If no introspector available (unknown forge), warn and skip
if os.Getenv("WAVE_SKIP_SCOPE_CHECK") != "" {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

minor - os.Getenv("WAVE_SKIP_SCOPE_CHECK") != "" treats false or 0 as set. An explicit opt-out disables all scope validation, though docs list it as a bool. Parse it as a boolean like the other WAVE_* flags; bypass only when true.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(scope): 3 token-scope enforcement gaps — silent skips on error/unsupported

2 participants