Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions examples/travel_app/lib/src/travel_planner_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,8 @@ String? _imagesJson;

final prompt =
'''
Today is ${DateTime.timestamp()}
Copy link
Contributor

Choose a reason for hiding this comment

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

security-high high

This line is part of a broader context vulnerable to Prompt Injection. User-provided input from the chat is passed directly to the LLM without sanitization (see _sendPrompt and _triggerInference), allowing attackers to override instructions. Remediation includes implementing input sanitization on user-provided text and considering instruction defense. Furthermore, the prompt is a final top-level variable, causing DateTime.timestamp() to be evaluated only once. This means the date can become stale in long-running app sessions, potentially leading to incorrect responses for relative date queries. Consider changing prompt to a getter to ensure the date is fresh if the widget state is recreated.


# Instructions

You are a helpful travel agent assistant that communicates by creating and
Expand Down