Описание
OpenMetadata vulnerable to a SpEL Injection in GET /api/v1/policies/validation/condition/<expr> (GHSL-2023-236)
SpEL Injection in GET /api/v1/policies/validation/condition/<expr> (GHSL-2023-236)
Please note, only authenticated users have access to PUT / POST APIS for /api/v1/policies. Non authenticated users will not be able to access these APIs to exploit the vulnerability. A user must exist in OpenMetadata and have authenticated themselves to exploit this vulnerability.
The CompiledRule::validateExpression method evaluates an SpEL expression using an StandardEvaluationContext, allowing the expression to reach and interact with Java classes such as java.lang.Runtime, leading to Remote Code Execution. The /api/v1/policies/validation/condition/<expression> endpoint passes user-controlled data CompiledRule::validateExpession allowing authenticated (non-admin) users to execute arbitrary system commands on the underlaying operating system.
Snippet from PolicyResource.java
In addition, there is a missing authorization check since Authorizer.authorize() is never called in the affected path and therefore any authenticated non-admin user is able to trigger this endpoint and evaluate arbitrary SpEL expressions leading to arbitrary command execution.
This vulnerability was discovered with the help of CodeQL's Expression language injection (Spring) query.
Proof of concept
- Prepare the payload
- Encode
touch /tmp/pwnedin Base64 =>dG91Y2ggL3RtcC9wd25lZA== - SpEL expression to run system command:
T(java.lang.Runtime).getRuntime().exec(new java.lang.String(T(java.util.Base64).getDecoder().decode("dG91Y2ggL3RtcC9wd25lZA=="))) - Encode the payload using URL encoding:
- Encode
- Send the payload using a valid JWT token:
- Verify that a file called
/tmp/pwnedwas created in the OpenMetadata server
Impact
This issue may lead to Remote Code Execution by a registered and authenticated user.
Remediation
Use SimpleEvaluationContext to exclude references to Java types, constructors, and bean references.
Ссылки
- https://github.com/open-metadata/OpenMetadata/security/advisories/GHSA-5xv3-fm7g-865r
- https://nvd.nist.gov/vuln/detail/CVE-2024-28848
- https://codeql.github.com/codeql-query-help/java/java-spel-expression-injection
- https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/CompiledRule.java#L51
- https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-service/src/main/java/org/openmetadata/service/security/policyevaluator/CompiledRule.java#L57
- https://securitylab.github.com/advisories/GHSL-2023-235_GHSL-2023-237_Open_Metadata
Пакеты
org.open-metadata:openmetadata-service
< 1.2.4
1.2.4
Связанные уязвимости
OpenMetadata is a unified platform for discovery, observability, and governance powered by a central metadata repository, in-depth lineage, and seamless team collaboration. The `CompiledRule::validateExpression` method evaluates an SpEL expression using an `StandardEvaluationContext`, allowing the expression to reach and interact with Java classes such as `java.lang.Runtime`, leading to Remote Code Execution. The `/api/v1/policies/validation/condition/<expression>` endpoint passes user-controlled data `CompiledRule::validateExpession` allowing authenticated (non-admin) users to execute arbitrary system commands on the underlaying operating system. In addition, there is a missing authorization check since `Authorizer.authorize()` is never called in the affected path and therefore any authenticated non-admin user is able to trigger this endpoint and evaluate arbitrary SpEL expressions leading to arbitrary command execution. This vulnerability was discovered with the help of CodeQL's E
Уязвимость метода CompiledRule::validateExpression (/api/v1/policies/validation/condition/) платформы для управления метаданными OpenMetadata, позволяющая нарушителю выполнить произвольный код