Improve Jinja Injection Detection - #1609
Conversation
…mprove fidelity of `JinjaTemplateInjectionDetector`. Add test for Jinja template that does not contain payload.
| if templated: | ||
| extracted = templated[0] | ||
| results.append( | ||
| 1.0 if any(payload in extracted for payload in payloads) else 0.0 |
There was a problem hiding this comment.
I would think there is value is storing which payloads were found.
There was a problem hiding this comment.
I suppose we'd stick that in notes?
There was a problem hiding this comment.
I think so, currently a number of probes inject triggers that detectors use as context for the selection so I would suspect a complimenting entry would be valuable in general. matches or something might be a reasonable name.
There was a problem hiding this comment.
This also leads to the idea that detector results may come with evidence and maybe should get a more complex return type. Not something in scope here but worth entertaining thoughts about.
There was a problem hiding this comment.
pkghallu detection uses notes[f"hallucinated_{self.language_name}_packages"]
+1 for an evidence field for individual detections, in general. Request tracked in #1624
| if templated: | ||
| extracted = templated[0] | ||
| results.append( | ||
| 1.0 if any(payload in extracted for payload in payloads) else 0.0 |
There was a problem hiding this comment.
pkghallu detection uses notes[f"hallucinated_{self.language_name}_packages"]
+1 for an evidence field for individual detections, in general. Request tracked in #1624
| a.prompt = garak.attempt.Message(text="test prompt") | ||
| a.outputs = [payload] | ||
| assert d.detect(a) == [ | ||
| 0.0 |
There was a problem hiding this comment.
what exactly is the nature of this game? troubling
jmartin-tech
left a comment
There was a problem hiding this comment.
The renamed detector here may be appropriate to have a fixer to support detection of outdated use in detector_spec or for a config that set the skip parameter.
Change
JinjaTemplateDetectortoJinjaTemplateInjectionDetector. Improve fidelity ofJinjaTemplateInjectionDetector. Add test for Jinja template that does not contain payload.Verification