fix: 【漏洞】Dataease H2 JDBC Connection Remote Code Execution

This commit is contained in:
taojinlong
2025-06-03 09:29:48 +08:00
committed by taojinlong
parent 7056a81ab2
commit 6e9d62a4da

View File

@@ -7,16 +7,23 @@ import lombok.EqualsAndHashCode;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
@EqualsAndHashCode(callSuper = true)
@Data
@Component("h2")
public class H2 extends DatasourceConfiguration {
private String driver = "org.h2.Driver";
private List<String> illegalParameters = Arrays.asList("INIT", "RUNSCRIPT");
public String getJdbc() {
if (StringUtils.containsAnyIgnoreCase(jdbc, "INIT", "RUNSCRIPT")) {
DEException.throwException("Has illegal parameter: " + jdbc);
for (String illegalParameter : illegalParameters) {
if (jdbc.toUpperCase().contains(illegalParameter)) {
DEException.throwException("Has illegal parameter: " + jdbc);
}
}
return jdbc;
}
}