← Latest papers
💻 computer science

PromptMark: A Prompt-Guided Iterative-Feedback Framework for Source Code Watermarking

PromptMark is a black-box, prompt-guided framework that embeds detectable watermarks into AI-generated source code through structured input instructions and iterative feedback, achieving strong attribution without compromising code functionality or requiring access to model internals.

Original authors: Istiaq Ahmed Fahad, Mridha Md. Nafis Fuad, Kazi Sakib

Published 2026-06-23
📖 5 min read🧠 Deep dive

Original authors: Istiaq Ahmed Fahad, Mridha Md. Nafis Fuad, Kazi Sakib

Original paper licensed under CC BY 4.0 (http://creativecommons.org/licenses/by/4.0/). This is an AI-generated explanation of the paper below. It is not written or endorsed by the authors. For technical accuracy, refer to the original paper. Read full disclaimer

Imagine you are a baker who hires a very talented, but invisible, robot chef to bake thousands of loaves of bread every day. You want to know which loaf was baked by your robot and which one was baked by a human competitor, but the robot doesn't leave a signature, and the bread looks exactly the same on the outside.

This is the problem PromptMark solves, but instead of bread, it's about computer code written by Artificial Intelligence (AI).

Here is how the paper explains the solution, broken down into simple concepts:

1. The Problem: The "Black Box" Chef

In the real world, most developers don't own the AI models they use; they rent them through a "black box" service (like a restaurant where you can't see the kitchen).

  • The Challenge: You can't peek inside the robot's brain to change how it thinks (this is called "white-box" access). You can only give it a recipe (a prompt) and wait for the dish (the code).
  • The Risk: If the AI writes code that breaks or steals credit, it's hard to prove it was the AI. Also, if you try to force the AI to write code in a weird way to mark it, the code might stop working (like a robot trying to bake bread with a hammer).

2. The Solution: The "Green List" Recipe

The researchers created a method called PromptMark. Instead of trying to hack the robot's brain, they simply change the instructions they give it.

Think of it like giving the robot chef a special rule: "For every new ingredient name you invent, you must start the name with a letter from this specific 'Green List' (like A, B, or C)."

  • The Green List: This is a secret list of letters (e.g., A, B, C) chosen based on a secret key.
  • The Red List: These are letters the robot is told to avoid starting names with.
  • The Trick: The robot follows these rules so well that it starts naming its variables (like apple_count or banana_loop) with Green letters much more often than a human would naturally.

3. The "Iterative Feedback" Loop: The Taste Test

Sometimes, the robot might forget the rule or write code that doesn't work because it's trying too hard to follow the rule. To fix this, PromptMark uses a feedback loop:

  1. Round 1: The robot writes the code.
  2. The Check: A human (or another computer) checks two things:
    • Does the code actually work? (Did the bread rise?)
    • Did the robot follow the "Green List" rule enough? (Are there enough A, B, C names?)
  3. The Feedback: If the code is broken, the robot is told, "Fix the logic." If the code works but the Green List rule is weak, the robot is told, "Great job, but use more 'A' names next time."
  4. Round 2: The robot tries again with the new instructions.

It keeps doing this until the code is perfect and the watermark is strong.

4. The Detection: The "Statistical Detective"

How do you know if a piece of code was made by the AI? You don't need to see the secret key. You just look at the names.

  • Natural Code: Humans name things randomly. If you look at 100 variables, maybe 10 start with 'A', 10 with 'B', etc. It's a balanced mix.
  • Watermarked Code: Because the AI was forced to use the "Green List," you will see a strange pattern. Maybe 60% of the names start with 'A', 'B', or 'C'.
  • The Test: A statistical test (like a math detector) counts these letters. If the pattern is too strong to be a coincidence, it shouts, "This was written by the AI!"

5. Why It's Special

The paper claims this method is special for three reasons:

  • It's Invisible: The code still looks normal and works perfectly. The "watermark" is just a subtle pattern in the names, like a hidden message in a song's lyrics that you only notice if you know the pattern.
  • It Works on Black Boxes: You don't need to own the AI or see its internal code. You just talk to it like a normal user.
  • It's Secure: The "Green List" is generated using a secret key (like a password). Only someone with that key knows which letters to look for, making it hard for others to fake the watermark.

The Results

The researchers tested this on two famous sets of coding problems (MBPP and HumanEval) using two different AI models (Gemini and Claude).

  • Success Rate: The method successfully marked the code about 90% to 98% of the time without breaking the code.
  • Quality: The code remained just as good as code written without the watermark.

The Limitations (What the paper admits)

  • Renaming Attacks: If someone takes the watermarked code and manually changes all the variable names to something else, the watermark disappears. The paper notes that while the method is good, it isn't magic; a determined human could erase the signal by rewriting the code.
  • Language Specific: The study was done on Python code. The paper warns that languages with different naming rules might behave differently.

In short, PromptMark is a way to whisper a secret instruction to an AI chef: "Name your ingredients with these specific letters," allowing you to later prove, with math, that the AI made the dish, all without ruining the taste of the food.

Drowning in papers in your field?

Get daily digests of the most novel papers matching your research keywords — with technical summaries, in your language.

Try Digest →