Skip to content

Regex in STAN falsely detects the word “Understand” as prompt injection #61

Description

@Sarthak422004

Description:

Problem

The current regex used in STAN is incorrectly flagging the word “Understand” as a prompt injection attempt.

This causes false positives when normal text contains words such as:

  • Understand
  • Understanding
  • Understood

Example

Input:

I understand the instructions and will proceed.

Expected behavior:

  • The message should pass normally without being flagged.

Actual behavior:

  • The regex triggers the prompt-injection detection.

Possible Cause

It looks like the regex is matching the substring "stand" or another partial pattern inside the word “Understand”, which leads to unintended matches.

Impact

  • Normal user messages are incorrectly blocked.
  • Reduces usability and reliability of the prompt-injection detection.
  • Could affect any sentence containing common words like “understand”.

Suggested Fix

  • Update the regex to match whole words only (for example using word boundaries \b).

  • Add test cases for common words such as:

    • understand
    • understanding
    • standalone
    • standard

Additional Context

This issue appears consistently whenever natural conversational text is used, especially in instruction-style messages.


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions