T09 · Insecure Skill Coding Practices
- Location
portainer.sh:29- Finding
TLS Certificate Verification Disabled for Authenticated Portainer Requests
- Content
View full analysis
Vulnerability Details
File Location:
portainer.sh, lines 29–39
Vulnerability Type: Improper certificate validation
Risk Level: HighVulnerable Code
bash api_get() { curl -s -k -H "$AUTH_HEADER" "$API$1" } api_post() { curl -s -k -X POST -H "$AUTH_HEADER" -H "Content-Type: application/json" "$API$1" -d "$2" } api_put() { curl -s -k -X PUT -H "$AUTH_HEADER" -H "Content-Type: application/json" "$API$1" -d "$2" }Technical Analysis
The
-koption instructscurlto accept an HTTPS server certificate without validating its authenticity. Every request made through these functions includes the Portainer API key in theX-API-Keyheader.Disabling certificate validation eliminates the server-authentication protection provided by TLS. An attacker who can intercept or redirect network traffic can present an arbitrary certificate, receive the API key, inspect requests, and supply forged API responses. The affected functions include both read operations and privileged operations such as starting or stopping containers and redeploying stacks.
Although contacting the configured Portainer server is necessary for the declared functionality, disabling certificate validation is not necessary and exposes credentials beyond the minimum safe privilege boundary.
Attack Path
- A user configures an HTTPS Portainer URL and invokes the script.
- An attacker gains a network interception position or manipulates DNS or routing.
- The attacker presents a self-signed or otherwise invalid certificate.
- Because
curl -kdisables validation, the script accepts the certificate. - The script sends the
X-API-Keyheader to the attacker-controlled endpoint. - The attacker reuses the stolen key against the genuine Portainer server.
- The attacker performs any container, stack, endpoint, or log operation authorized by that API token.
Impact Assessment
Successful exploi ...[truncated 445 chars]
- Remediation
View remediation
Remediation Suggestions
-
Remove the
-koption from everycurlinvocation. -
Require Portainer to use a certificate trusted by the operating system.
-
For deployments using a private certificate authority, support an explicit CA bundle, for example:
bash curl --fail-with-body --silent --show-error \ --cacert "$PORTAINER_CA_FILE" \ -H "$AUTH_HEADER" \ "$API$1" -
Do not silently fall back to insecure certificate handling when CA validation fails.
-
Consider certificate or public-key pinning where the deployment model supports secure pin rotation.
-
Add
--fail-with-bodyand--show-errorso HTTP and transport failures are not mistaken for successful operations. -
Document the certificate requirements and provide instructions for installing a private CA securely.
-
