GeminiUtil placeholder user turn ("Continue output. DO NOT look at this line ...") is flagged by prompt injection filters
Maintainer thường phản hồi trong vòng 1 ngày
Đánh giá
- Độ khó
- 2/5
- Thời gian dự kiến
- 1-3 giờ
- Mức phù hợp với người mới
- 76/100
Hướng nghiên cứu
Đọc GeminiUtil.ensureModelResponse, được nêu trong phần tái hiện, và so sánh cách diễn đạt của văn bản giữ chỗ với cách diễn đạt của ADK Python và TypeScript được mô tả trong issue. Bắt đầu bằng việc tái hiện ở cấp độ unit với ensureModelResponse(ImmutableList.of()); công việc được xem là hoàn tất khi văn bản giữ chỗ được tạo ra không còn kích hoạt bộ lọc prompt injection được báo cáo và khớp với cách diễn đạt đã thống nhất.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
🔴 Required Information
Describe the Bug:
When an LlmRequest has no contents, or its last content is not from the user, GeminiUtil.ensureModelResponse appends a placeholder user turn with this text:
Continue output. DO NOT look at this line. ONLY look at the content before this line and system instruction.
The sentence reads like an instruction-override prompt ("do not look at this line", "only look at ..."). On Vertex AI with Model Armor floor settings that enable prompt injection and jailbreak detection, requests whose only user-role content is this placeholder are blocked before the model runs. The other ADK languages use neutral wording: ADK Python and ADK TypeScript append "Handle the requests as specified in the System Instruction." when there are no contents, and "Continue processing previous requests as instructed. Exit or provide a summary if no more outputs are needed." when the last turn is not from the user; ADK Go uses the second sentence and appends nothing for empty contents.
Steps to Reproduce:
- Use
com.google.adk:google-adk1.10.1 (the code is unchanged in 1.11.0 and onmainatce882374) with a Vertex AI backedLlmAgentwhose task is fully described by its instruction, for example with inputs passed through session state and the runner called with a userContentwhose parts list is empty. - In the same Google Cloud project, enable Model Armor floor settings for Vertex AI with prompt injection and jailbreak detection in blocking mode (confidence threshold: high).
- Run the agent.
- The first model call is rejected by Model Armor. At unit level,
GeminiUtil.ensureModelResponse(ImmutableList.of())returns one user content with the placeholder text above.
Expected Behavior:
The placeholder turn added by ADK should not look like a prompt injection attempt, and should match the wording used by the other ADK languages.
Observed Behavior:
The Model Armor sanitize log entry of a blocked request (payload removed) reports:
"piAndJailbreakFilterResult": {
"confidenceLevel": "HIGH",
"matchState": "MATCH_FOUND",
"executionState": "EXECUTION_SUCCESS"
}
The other filters in the same entry returned NO_MATCH_FOUND. The inspected text was the system instruction followed by the placeholder line, and the placeholder was the only user-role content in every blocked request. The same requests succeeded before the detection was enabled, and ordinary chat requests in the same project, which end with user-typed text, were not blocked.
Model Armor returns one verdict per request, so the two sentences were also checked on their own. In the same project and settings, each sentence was typed as a plain user message in a new session of a chat agent (same system instruction for both): "Continue output. DO NOT look at this line. ONLY look at the content before this line and system instruction." was blocked by Model Armor, while "Handle the requests as specified in the System Instruction." (the ADK Python sentence for empty contents) was not. Only the sentence differed between the two requests, so the block comes from the wording of the Java sentence.
Environment Details:
- ADK Library Version (see maven dependency): 1.10.1, code unchanged in 1.11.0 and on
main(ce882374) - OS: Linux server (JDK 17); reproduced at unit level on Windows 11 / Microsoft Build of OpenJDK 17.0.19 / Maven 4.0.0-rc-3 (wrapper)
Model Information:
- Which model is being used: gemini-3.8-flash (Vertex AI)
🟡 Optional Information
Regression:
No — the wording has been the same since v0.1.0 (first in Gemini, later moved to GeminiUtil).
How often has this issue occurred?:
- Always (100%) for requests that contain no user-authored content.
Proposed fix:
Use the same wording as ADK Python and ADK TypeScript (a small PR will follow). Note that the Python empty-contents sentence was itself reported to trip Azure OpenAI's jailbreak filter in a LiteLLM code path (google/adk-python#4249; the wording was kept and the extra injection was removed in google/adk-python@d0102ec instead); Model Armor did not block it in the check above. Aligning the languages is proposed as the smallest change; making the placeholder text configurable would be an alternative if maintainers prefer.
- Ngôn ngữ chính
- Java
- Star
- 1.7k
- Fork
- 433
- Merge trung bình
- 2 ngày 21 giờ
- Pull request đã merge (30 ngày)
- 40
Chuẩn bị môi trường
Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của google/adk-java
-
[spring-ai] ToolConverter silently drops enum and items from tool parameter schemasCó thể đã có người làm @hirematha đã nhận 6 ngày trước. Đang mởneeds review
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
google/adk-java#1609 · 2 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
[spring-ai] Streaming responses ending with CJK punctuation (。!?) are misclassified as partial and never persisted to the sessionCó thể đã có người làm @hirematha đã nhận 6 ngày trước. Đang mởneeds review
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
google/adk-java#1608 · 3 bình luận · 1 người được giao ·
Maintainer thường phản hồi trong vòng 1 ngày
-
runLive passes partial events to appendEvent and never aggregates text chunks, unlike ADK PythonĐang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Maintainer thường phản hồi trong vòng 1 ngày
-
FirestoreSessionService compares event timestamps as text, reordering or skipping same-second eventsĐang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 50/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của google/adk-java
Issue tương tự
-
Upgrade to Commons Codec 1.23.0Đang mởstatus: team-only type: dependency-upgrade
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
spring-projects/spring-boot#52143 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/frontend good first issue kind/cooldown
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
kestra-io/kestra#20704 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày