Fork me on GitHub
#graphql
<
2021-03-30
>
steveb8n07:03:46

Q: I’ve been using ZAP to scan a Lacinia API for vulnerabilities. One that turned up is https://www.zaproxy.org/docs/alerts/40012/ which can be triggered by passing <script>alert(1);</script> in a query enum variable value

steveb8n07:03:33

this doesn’t reach my resolvers because it doesn’t match the schema so the Lacinia parse rejects it but returns the value back to the client

steveb8n07:03:06

while it’s low risk for a GraphQL response, I’d prefer to suppress this reflection

steveb8n07:03:46

I can think of 1 way : an interceptor that detects/removes the <script> tag.

steveb8n07:03:03

has anyone else dealt with or fixed this in some idiomatic way?

steveb8n08:03:08

hmm, an interceptor doesn’t see the :extensions data in the response. does anyone know how I can access/transform the :extensions / :errors data in a response?

steveb8n08:03:37

scratch that, an interceptor can see the :errors in the JSON response body. I’d prefer to do this transformation earlier i.e. before it’s converted to JSON. looking into that next

Lennart Buit10:03:26

Just out of interest, how would this attack work?

steveb8n22:03:48

@UDF11HLKC I don’t know and, because I control the client, it’s very unlikely. That said: 1/ I don’t assume I know all the hacker tricks 2/ this is for a security audit so I want a clean scan to make that go smoothly

steveb8n00:03:54

I was able to inject an interceptor :after the json-body interceptor and redact these script tags so that’s one down