apoc.ml procedures send server-configured API keys and AWS credentials to caller-supplied endpoints
Description
Impact
The apoc.ml.* procedures of APOC Extended can use credentials that the server holds:
- the API key configured via
apoc.openai.key, used by the OpenAI, Azure OpenAI, Anthropic, HuggingFace and Mixedbread procedures (apoc.ml.openai.*,apoc.ml.mixedbread.*and the procedures built on them) - the AWS credentials configured via
apoc.aws.key.id/apoc.aws.secret.key, used byapoc.ml.bedrock.*andapoc.ml.sagemaker.*
If the caller did not pass credentials in the call-time configuration, these server-held credentials were attached to the outbound request. At the same time, the destination of that request could be chosen by the caller through the endpoint (or path) configuration option, without any check.
As a result, any authenticated user allowed to execute these procedures could make the server send the configured API key (as Authorization, x-api-key or api-key header) or AWS-signed requests to a host under their control, and thereby obtain a credential they cannot read through dbms.listConfig, SHOW SETTINGS or any other admin-gated channel. The leaked credential is valid outside of Neo4j and can be used against the third-party provider account.
Exploitation requires an authenticated Neo4j session with permission to execute the affected procedures (granted to PUBLIC by default in Neo4j Enterprise Edition) and a deployment that stores the provider credentials server-side, which is the configuration recommended by the APOC documentation.
apoc.ml.vertexai.* is not affected, as its access token is a mandatory procedure argument with no server-side fallback.
Patches
Fixed in APOC Extended 5.26.5 (#4591). A server-held API key is now only sent to the provider default endpoint or to the endpoint configured via apoc.ml.openai.url, compared by scheme, host and port. Server-held AWS credentials only sign HTTPS requests to Bedrock or SageMaker service hosts. For any other endpoint the caller has to supply their own credentials, otherwise the procedure fails before any request is sent.
Behavior change: deployments that combine the server-held key with a caller-supplied endpoint (e.g. a proxy or a self-hosted, OpenAI-compatible server) must configure that endpoint via apoc.ml.openai.url, or pass the credentials explicitly in the call.
The 2026.x releases (2026.01.0 to 2026.04.0) are still affected; the fix is in 2026.10.0.
Workarounds
If you cannot upgrade:
- Do not configure
apoc.openai.key,apoc.aws.key.idorapoc.aws.secret.keyserver-side; pass credentials explicitly in each call instead. - Or restrict who can run the affected procedures, e.g. with
DENY EXECUTE PROCEDURE apoc.ml.* ON DBMS TO <role>or via the procedures allowlist. - If untrusted users had access to these procedures, rotate the configured provider API keys and AWS credentials.
For more information
If you have any questions or comments about this advisory:
- Open an issue in neo4j-apoc-procedures
- Email us at security@neo4j.com
Credits
We want to publicly recognise the contribution of Amitay Shahar.