IP Library › Granted Patent US 12,399,991
Granted Patent B2
US 12,399,991 · App. 18/235,836 · Granted Aug 26, 2025

Signing large language model prompts to prevent unintended response

Inventors: Colin Bruce Clement (Seattle, WA); Shengyu Fu (Redmond, WA); Neelakantan Sundaresan (Bellevue, WA); Dongjiang You (Kirkland, WA)
Assignee: Microsoft Technology Licensing, LLC.
G06F21/56G06F2221/034
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 12,399,991
App. No.
18/235,836
Granted
Aug 26, 2025
Kind
B2
Abstract

A technique to prevent a prompt injection attack utilizes a security agent to sign a large language model prompt with a secret that is isolated from the user application or device that generates a user prompt. The secret is tailored for a specific user identifier and session identifier. The large language model is instructed to repeat the secret in each response. The security agent retrieves the response from the large language model and checks for the secret. When the secret is not part of the response, an error message is forwarded to the user application instead of the response.

Claims (61)

1. A system comprising:

a processor; and

a memory that stores a program configured to be executed by the processor, the program comprising instructions that when executed by the processor perform acts that:

provide instructions to a large language model (LLM), wherein the instructions indicate that the LLM is to repeat a secret in a response generated by the LLM when given a user prompt that includes the secret, wherein the instructions indicate a scope of the response that defines data to be included and not included in the response;

receive a network message from a user application, wherein the network message comprises the user prompt destined for the LLM, a user identifier and a session identifier;

obtain a secret associated with the user identifier and the session identifier;

generate a LLM prompt comprising the secret and the user prompt;

receive a response from the LLM based on the LLM prompt; and

when the response fails to include the secret, return an error message.

2. The system of claim 1 , wherein the program comprises instructions that when executed by the processor perform acts that:

when the response from the large language model includes the secret, extract the secret from the response and return a remaining portion of the response to the user application.

3. The system of claim 1 , wherein the program comprises instructions that when executed by the processor perform acts that:

store the secret in a memory not accessible by the large language model and the user application.

4. The system of claim 1 , wherein the program comprises instructions that when executed by the processor perform acts that:

associate a turn count and a turn count limit for the secret; and

when the turn count of the secret exceeds a limit of the turn count, create a new secret for the user identifier and session identifier.

5. The system of claim 1 , wherein the program comprises instructions that when executed by the processor perform acts that:

associate a turn count for the secret; and

update the turn count for each LLM prompt generated.

6. The system of claim 1 , wherein the secret comprises an ordered sequence of natural language words.

7. The system of claim 1 , wherein the session identifier is unique for each user session.

8. The system of claim 1 , wherein the user identifier is an Internet Protocol address associated with a user computing device.

9. A computer-implemented method, comprising:

providing instructions to a large language model (LLM) for answering a conversational query, wherein the instructions indicate a scope of a response to the conversational query, wherein the conversational query is associated with a single user session;

receiving a first user prompt of the conversational query for the LLM to return a first response, wherein the first user prompt is associated with a user identifier and a session identifier of the single user session;

constructing a secret for the user identifier and the session identifier;

creating a LLM prompt comprising the secret and the first user prompt;

receiving the first response from the large language model given the LLM prompt;

detecting a prompt injection attack when the first response fails to include the secret in the first response; and

returning an error message upon detection of the prompt injection attack.

10. The computer-implemented method of claim 9 , comprising:

receiving a second user prompt of the conversational query; and

creating a second LLM prompt comprises the secret and the second user prompt.

11. The computer-implemented method of claim 9 , comprising:

associating a turn count with the secret; and

creating a new secret when the turn count exceeds a turn count limit.

12. The computer-implemented method of claim 9 , comprising:

associating a turn count with the secret; and

updating the turn count when the secret is used in each LLM prompt.

13. The computer-implemented method of claim 9 , comprising:

extracting the secret from the response and returning a remaining portion of the response.

14. The computer-implemented method of claim 9 , comprising:

receiving the user prompt via a network from a user application; and

storing the secret in a memory not accessible by the large language model and the user application.

15. The computer-implemented method of claim 9 , wherein the large language model is a neural transformer model with attention.

16. A hardware device having stored thereon computer executable instructions that are structured to be executable by a processor of a computing device to thereby cause the computing device to perform actions that:

provide a system prompt to a large language model (LLM) that comprises instructions that instruct the LLM to repeat a secret in a response generated by the large language model (LLM) given a user prompt and a goal for the response generated by the LLM, wherein the goal indicates a restriction on actions not to be performed by the LLM;

receive a first network message from a user application, wherein the first network message comprises a first user prompt destined for the LLM, a user identifier and a session identifier;

obtain a first secret associated with the user identifier and the session identifier;

generate a LLM prompt comprising the first secret and the first user prompt;

receive a response from the LLM based on the LLM prompt; and

when the response fails to include the first secret, return an error message to the user application.

17. The hardware device of claim 16 , having stored thereon computer executable instructions that are structured to be executable by the processor of the computing device to thereby cause the computing device to perform actions that:

generate a new secret when usage of the first secret exceeds a threshold limit associated with the first secret.

18. The hardware device of claim 16 , having stored thereon computer executable instructions that are structured to be executable by the processor of the computing device to thereby cause the computing device to perform actions that:

store the first secret in a memory not accessible by the large language model and the user application.

19. The hardware device of claim 16 , having stored thereon computer executable instructions that are structured to be executable by the processor of the computing device to thereby cause the computing device to perform actions that:

receive a second network message from the user application, wherein second network message comprises a second user prompt destined for the LLM, wherein the second network message is associated with the user identifier and the session identifier,

obtain the first secret of the user identifier and the session identifier; and

generate a second LLM prompt comprising the first secret and the second user prompt.

20. The hardware device of claim 16 , wherein the LLM comprises a neural transformer model with attention.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 19, 2023
From: CLEMENT, COLIN BRUCE; FU, SHENGYU; SUNDARESAN, NEELAKANTAN; YOU, DONGJIANG
To: MICROSOFT TECHNOLOGY LICENSING, LLC.
Reel/Frame 064642/0261 →
Continuity (2)
Provisional Application 63467301 · May 17, 2023
Related Publication 20240386103A1 · Nov 21, 2024
References Cited (15)
US 11514365B2 · Cheruvu · 2022 [cited by examiner]
US 12052206B1 · Lai · 2024 [cited by examiner]
US 20180032576A1 · Romero · 2018 [cited by applicant]
US 20200012745A1 · Bain · 2020 [cited by applicant]
US 20200251111A1 · Temkin · 2020 [cited by applicant]
US 20230359903A1 · Cefalu · 2023 [cited by examiner]
US 20240054233A1 · Ohayon · 2024 [cited by examiner]
US 20240134974A1 · Moissinac · 2024 [cited by examiner]
US 20240403560A1 · Radu · 2024 [cited by examiner]
Simon Willison, Prompt Injection attacks against GPT-3, Sep. 12, 2022, Simon Willison's Weblog, 9 pages (Year: 2022). [cited by examiner]
Greshake, et al., “Not what you've signed up for: Compromising Real-World LLM-Integrated Applications with Indirect Prompt Injection”, Accessed on link https://arxiv.org/pdf/2302.12173v2.pdf, Retrieved on May 5, 2023, 3… [cited by applicant]
International Search Report and Written Opinion received for PCT Application No. PCT/US2024/028452, Sep. 10, 2024, 13 pages. [cited by applicant]
Xuchen, Suo, “Signed-Prompt: A New Approach to Prevent Prompt Injection Attacks Against LLM-Integrated Applications”, Retrieved from the URL: https://arxiv.org/pdf/2401.07612, Jan. 15, 2024, 7 Pages. [cited by applicant]
Daniels, Arnold, “Protecting against Prompt Injection in GPT”, Retrieved from: https://dev.to/jasny/protecting-against-prompt-injection-in-gpt-1gf8, Apr. 17, 2023, 9 Pages. [cited by applicant]
Perez, et al., “Ignore Previous Prompt: Attack Techniques For Language Models”, In Repository of arXiv:2211.09527v1, Nov. 17, 2022, pp. 1-21. [cited by applicant]