graphql

steveb8n 2021-03-30T07:21:46.005300Z

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

steveb8n 2021-03-30T07:22:33.005500Z

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

steveb8n 2021-03-30T07:23:06.005700Z

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

steveb8n 2021-03-30T07:23:46.005900Z

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

steveb8n 2021-03-30T07:24:03.006100Z

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

steveb8n 2021-03-30T08:15:08.006400Z

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?

steveb8n 2021-03-30T08:26:37.006600Z

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

2021-03-30T10:52:26.006800Z

Just out of interest, how would this attack work?

steveb8n 2021-03-30T22:03:48.007200Z

@lennart.buit 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