-
Notifications
You must be signed in to change notification settings - Fork 361
security: reject disable-xpia-prompt in strict mode at compile time #28057
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
8672603
17e4d46
655c213
e4c68ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -73,6 +73,37 @@ func (c *Compiler) validateStrictDeprecatedFields(frontmatter map[string]any) er | |
| return nil | ||
| } | ||
|
|
||
| // validateStrictDisableXPIA refuses use of the disable-xpia-prompt feature flag in strict mode. | ||
| // Disabling XPIA (Cross-Prompt Injection Attack) protection removes the primary defense against | ||
| // prompt-injection attacks in production workflows. | ||
| func (c *Compiler) validateStrictDisableXPIA(frontmatter map[string]any) error { | ||
| featuresValue, exists := frontmatter["features"] | ||
| if !exists { | ||
| return nil | ||
| } | ||
| featuresMap, ok := featuresValue.(map[string]any) | ||
| if !ok { | ||
| return nil | ||
| } | ||
| flagVal, exists := featuresMap["disable-xpia-prompt"] | ||
| if !exists { | ||
| return nil | ||
| } | ||
| // Only reject when the flag is explicitly enabled (true / non-empty string) | ||
| enabled := false | ||
| switch v := flagVal.(type) { | ||
| case bool: | ||
| enabled = v | ||
| case string: | ||
| enabled = v != "" | ||
| } | ||
|
Comment on lines
+84
to
+99
|
||
| if !enabled { | ||
| return nil | ||
| } | ||
| strictModeValidationLog.Printf("disable-xpia-prompt validation failed: feature flag enabled in strict mode") | ||
| return errors.New("strict mode: 'disable-xpia-prompt: true' is not allowed because it removes XPIA (Cross-Prompt Injection Attack) protection from the workflow. This eliminates the primary defense against prompt-injection attacks. Remove the disable-xpia-prompt feature flag or set 'strict: false' to disable strict mode") | ||
| } | ||
|
|
||
| // validateStrictFirewall requires firewall to be enabled in strict mode for copilot and codex engines | ||
| // when network domains are provided (non-wildcard). | ||
| // In strict mode, ALL engines (regardless of LLM gateway support) disallow sandbox.agent: false. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,6 +30,7 @@ var strictModeValidationLog = newValidationLogger("strict_mode") | |
| // 3. validateStrictMCPNetwork() - Requires top-level network config for container-based MCP servers | ||
| // 4. validateStrictTools() - Validates tools configuration (e.g., serena local mode) | ||
| // 5. validateStrictDeprecatedFields() - Refuses deprecated fields | ||
| // 6. validateStrictDisableXPIA() - Refuses disable-xpia-prompt feature flag | ||
| // | ||
| // Note: Env secrets validation (validateEnvSecrets) is called separately outside of strict mode | ||
| // to emit warnings in non-strict mode and errors in strict mode. | ||
|
|
@@ -83,6 +84,13 @@ func (c *Compiler) validateStrictMode(frontmatter map[string]any, networkPermiss | |
| } | ||
| } | ||
|
|
||
| // 6. Refuse disable-xpia-prompt feature flag | ||
| if err := c.validateStrictDisableXPIA(frontmatter); err != nil { | ||
| if returnErr := collector.Add(err); returnErr != nil { | ||
| return returnErr // Fail-fast mode | ||
| } | ||
| } | ||
|
Comment on lines
+87
to
+92
|
||
|
|
||
| strictModeValidationLog.Printf("Strict mode validation completed: error_count=%d", collector.Count()) | ||
|
|
||
| return collector.FormattedError("strict mode") | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test name implies bash tool configuration affects validation, but validateFeatures() currently only validates
features.action-tagand does not inspect ParsedTools. Consider renaming the test (or adding a comment) to avoid implying a dependency that doesn’t exist.