{"record":{"id":"09e7a90f1ceb9d3e","repo":"moodle/moodle","slug":"uri-uri-contains-an-unsupported-host","errorCode":null,"errorMessage":"Uri '{$uri}' contains an unsupported host.","messagePattern":"Uri '(.+?)' contains an unsupported host\\.","errorType":"exception","errorClass":"CredentialsException","httpStatus":null,"severity":"error","filePath":"public/lib/aws-sdk/src/Credentials/EcsCredentialProvider.php","lineNumber":127,"sourceCode":"\n                        $isRetryable = $reason instanceof ConnectException;\n                        if ($isRetryable && ($this->attempts < $this->retries)) {\n                            sleep((int)pow(1.2, $this->attempts));\n                        } else {\n                            $msg = $reason->getMessage();\n                            throw new CredentialsException(\n                                sprintf('Error retrieving credentials from container metadata after attempt %d/%d (%s)', $this->attempts, $this->retries, $msg)\n                            );\n                        }\n                    }));\n                    $this->attempts++;\n                }\n\n                yield $credentials;\n            });\n        }\n\n        throw new CredentialsException(\"Uri '{$uri}' contains an unsupported host.\");\n    }\n\n    /**\n     * Returns the number of attempts that have been done.\n     *\n     * @return int\n     */\n    public function getAttempts(): int\n    {\n        return $this->attempts;\n    }\n\n    /**\n     * Retrieves authorization token.\n     *\n     * @return array|false|string\n     */\n    private function getEcsAuthToken()","sourceCodeStart":109,"sourceCodeEnd":145,"githubUrl":"https://github.com/moodle/moodle/blob/48ea8c33227277e916cdd4079dbecef448b37f2c/public/lib/aws-sdk/src/Credentials/EcsCredentialProvider.php#L109-L145","documentation":"The container credential provider rejects any AWS_CONTAINER_CREDENTIALS_FULL_URI whose host is not a link-local trusted address. isCompatibleUri() allows only https schemes, the ECS endpoint 169.254.170.2, the EKS pod identity agent 169.254.170.23 / fd00:ec2::23, or hosts resolving (via gethostbyname) to a loopback address; anything else throws this CredentialsException from __invoke before any request is made.","triggerScenarios":"Setting AWS_CONTAINER_CREDENTIALS_FULL_URI to a URL whose host is a public IP, an arbitrary external hostname resolving to a non-loopback IP, a malformed URL (parse_url fails to yield 'host'), or an http:// URL to a non-allowlisted host. The check runs before the HTTP request, so the error is thrown synchronously.","commonSituations":"Pointing FULL_URI at a custom local credentials server that is not on loopback (e.g. bound to a docker bridge IP or LAN address); forgetting the scheme so parse_url misparses the host; using http:// with a public endpoint in a self-managed container environment; typos like an extra path/space breaking the URL.","solutions":["Ensure the FULL_URI host is loopback (127.0.0.1/::1) — run your local credential server on 127.0.0.1 and use http://127.0.0.1:PORT/... .","Or use https:// with any host, which bypasses the host allowlist entirely.","Or use the standard link-local endpoints: http://169.254.170.2 (ECS) or 169.254.170.23 / fd00:ec2::23 (EKS pod identity).","Verify AWS_CONTAINER_CREDENTIALS_RELATIVE_URI (not FULL_URI) is the right variable when you intend to use the default ECS endpoint.","Print and parse the URI (parse_url) to confirm scheme/host are as expected."],"exampleFix":"// before\nexport AWS_CONTAINER_CREDENTIALS_FULL_URI=\"http://172.17.0.5:9000/creds\"\n\n// after (loopback or https)\nexport AWS_CONTAINER_CREDENTIALS_FULL_URI=\"http://127.0.0.1:9000/creds\"\n# or\nexport AWS_CONTAINER_CREDENTIALS_FULL_URI=\"https://creds.internal.local/creds\"","handlingStrategy":"validation","validationCode":"<?php\n$uri = getenv('AWS_CONTAINER_CREDENTIALS_FULL_URI');\nif ($uri !== false && $uri !== '') {\n    $p = parse_url($uri);\n    $ok = isset($p['scheme'], $p['host'])\n        && ($p['scheme'] === 'https'\n            || in_array(trim($p['host'], '[]'), ['169.254.170.2', '169.254.170.23', 'fd00:ec2::23'], true)\n            || str_starts_with(trim($p['host'], '[]'), '127.'));\n    if (!$ok) throw new RuntimeException(\"FULL_URI host not allowed: {$uri}\");\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Use loopback (127.0.0.1) or https for any custom credential endpoint","Prefer AWS_CONTAINER_CREDENTIALS_RELATIVE_URI when using the standard ECS endpoint","Validate the FULL_URI with parse_url before exporting it in your deployment config","Remember http:// is only permitted for link-local/loopback hosts"],"tags":["aws-sdk","credentials","ecs","uri","security"],"backgroundTag":"invalid-url","analyzedSha":"48ea8c33227277e916cdd4079dbecef448b37f2c","analyzedAt":"2026-09-14T20:34:48.527Z","contentChangedAt":"2026-09-14T20:34:48.527Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}