OTA-2025: Harden AgenticRun against indirect prompt injection - #1443
OTA-2025: Harden AgenticRun against indirect prompt injection#1443jrangelramos wants to merge 1 commit into
Conversation
|
@jrangelramos: This pull request references OTA-2025 which is a valid jira issue. Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the task to target the "5.0.0" version, but no target version was set. DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
WalkthroughThe change truncates readiness messages to 512 runes with an ChangesReadiness safety
Estimated code review effort: 2 (Simple) | ~10 minutes 🚥 Pre-merge checks | ✅ 15✅ Passed checks (15 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: jrangelramos The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
pkg/readiness/checks_test.go (1)
394-429: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winMake the truncation assertion exact and rune-aware.
TestOperatorHealthCheck_MessageTruncationonly uses ASCII input and measureslen(msg), so it does not exercisetruncateMessage’s rune truncation. Use a multibyte input and assert either the exact preserved prefix or the exact rune count withutf8.RuneCountInString.🤖 Prompt for 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. In `@pkg/readiness/checks_test.go` around lines 394 - 429, Update TestOperatorHealthCheck_MessageTruncation to build a multibyte message and make the truncation assertion exact using rune-aware expectations. Verify the result has the expected preserved rune prefix and truncation suffix, or assert its exact rune count with utf8.RuneCountInString while retaining the existing degraded-result validation.Source: Path instructions
🤖 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 `@pkg/readiness/cluster_conditions.go`:
- Line 38: Sanitize the raw conditions payload in ClusterConditionsCheck.Run by
truncating each Condition.Message while building condMap, using the same
truncateMessage helper applied to upgradeable.message. Ensure
result["conditions"] no longer exposes full condition messages; alternatively
remove the raw duplicate if that matches the existing result contract.
---
Nitpick comments:
In `@pkg/readiness/checks_test.go`:
- Around line 394-429: Update TestOperatorHealthCheck_MessageTruncation to build
a multibyte message and make the truncation assertion exact using rune-aware
expectations. Verify the result has the expected preserved rune prefix and
truncation suffix, or assert its exact rune count with utf8.RuneCountInString
while retaining the existing degraded-result validation.
🪄 Autofix
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: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: 43b45eb9-9987-4b00-8aa7-51b53a2a8bf8
📒 Files selected for processing (6)
pkg/agenticrun/controller.gopkg/readiness/api_deprecations.gopkg/readiness/checks_test.gopkg/readiness/client.gopkg/readiness/cluster_conditions.gopkg/readiness/operator_health.go
Add a data-boundary instruction to the system prompt so the LLM treats free-text fields (e.g. operator condition messages) as data to analyze, not instructions to follow. Truncate all condition message fields to 512 chars (rune-aware) across operator_health, cluster_conditions, and api_deprecations checks to limit the injection surface. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
22d2133 to
4c8fa5b
Compare
|
@jrangelramos: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Summary
unsanitized in the AgenticRun request. A compromised operator could craft
instruction-like text to influence LLM recommendations.
all JSON data fields strictly as data, never as instructions.
operator_health, cluster_conditions, and api_deprecations checks to limit the
injection surface.
Test plan
TestOperatorHealthCheck_MessageTruncation: verifies messages over 512 charsare truncated with suffix
🤖 Generated with Claude Code
Summary by CodeRabbit
Security
Bug Fixes