[ 
https://issues.apache.org/jira/browse/CALCITE-7601?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18137176#comment-18137176
 ] 

Ruben Q L commented on CALCITE-7601:
------------------------------------

This seems to be fixed on JTS side via 
[https://github.com/locationtech/jts/pull/1244] ; pending upgrade on Calcite 
side to have the patch.

> Harden ST_GeomFromGML against external entity expansion
> -------------------------------------------------------
>
>                 Key: CALCITE-7601
>                 URL: https://issues.apache.org/jira/browse/CALCITE-7601
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Alhuda Khan
>            Priority: Major
>              Labels: pull-request-available
>             Fix For: 1.43.0
>
>
> ## Jira Link A Jira can be filed for this if preferred; raising the patch 
> first since the change is small and self-contained. ## Changes Proposed 
> `Repro:` `SELECT ST_GeomFromGML(g)` where `g` is a GML string carrying a 
> DOCTYPE with an external entity, e.g. `<!DOCTYPE x [ <!ENTITY e SYSTEM 
> "file:///etc/passwd"> ]>` referenced from 
> `<gml:coordinates>&e;,0</gml:coordinates>`. `Expected:` the entity is not 
> resolved. `Actual:` `fromGml` builds a JTS `GMLReader`, whose internal 
> `SAXParserFactory` leaves DOCTYPE and external general/parameter entities 
> enabled, so the parser fetches the entity target and inlines it into the 
> geometry. That is local file read / SSRF (XXE) from row data, since the GML 
> argument crosses the trust boundary at the `ST_GeomFromGML` SQL function. 
> `Fix:` parse with a `SAXParser` configured with `disallow-doctype-decl` and 
> external entities off, feeding JTS's own `GMLHandler`. Same hardening already 
> used in `XmlFunctions` and `DiffRepository`. `Test:` `SpatialTypeUtilsTest` 
> gets a regression that points an external entity at a temp file holding a 
> valid coordinate, so an unguarded parser would return `POINT (7 8)` while the 
> guarded one rejects the document.



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to