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

ASF subversion and git services commented on KNOX-3442:
-------------------------------------------------------

Commit 38cc0f47bf384324cc1a7e77104227c1da8d57bf in knox's branch 
refs/heads/master from Sandor Molnar
[ https://gitbox.apache.org/repos/asf?p=knox.git;h=38cc0f47b ]

KNOX-3442: Reject INIT/RUNSCRIPT/ALIAS in H2 database name to prevent JDBC-URL 
code execution (#1383)

> Harden H2 JDBC URL construction against connection-string injection via 
> gateway.database.name
> ---------------------------------------------------------------------------------------------
>
>                 Key: KNOX-3442
>                 URL: https://issues.apache.org/jira/browse/KNOX-3442
>             Project: Apache Knox
>          Issue Type: Improvement
>          Components: Server
>    Affects Versions: 3.1.0
>            Reporter: Sandor Molnar
>            Assignee: Sandor Molnar
>            Priority: Major
>             Fix For: 3.1.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> KNOX-3401 added H2. H2DataSourceFactory builds the URL by raw concatenation:
> {noformat}
> String url = "jdbc:h2:" + gatewayConfig.getDatabaseName();   // :49
> {noformat}
> {{gateway.database.name}} comes straight from {{gateway-site.xml}}, 
> unvalidated. H2 URLs are an RCE sink: an appended {{;INIT=RUNSCRIPT FROM 
> 'http://…'}} (or CREATE ALIAS …) runs arbitrary code at datasource creation.
> The embedded path is safe ({{{}EmbeddedH2Database{}}} sets a trusted 
> {{securityDir}} file path), but a manually-configured non-embedded H2 
> deployment flows the raw value into the URL. Operator-controlled/trusted 
> config, so low severity, but cheap defense-in-depth.
> Fix: reject H2 code-execution tokens ({{{}INIT/RUNSCRIPT/ALIAS{}}}, 
> case-insensitive) in the name at URL construction, fail-fast. Not a blanket 
> {{';'}} ban, because valid H2 settings exist (e.g. 
> {{{}mem:knox;DB_CLOSE_DELAY=-1{}}}).



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to