security/JdbcSecurityUtil.java

JeecgBoot · jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/security/JdbcSecurityUtil.java · java · Apache-2.0
database

Security helper validating JDBC URLs and driver names against a blacklist/whitelist to prevent injection attacks.

// Source: https://github.com/jeecgboot/JeecgBoot | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
package org.jeecg.common.util.security;

import org.jeecg.common.exception.JeecgBootException;
import org.jeecg.common.util.oConvertUtils;

/**
 * JDBC连接安全校验工具类
 *
 * 修复说明:
 *   原实现仅检查 URL 中 '?' 之后的参数,且黑名单仅包含 5 个 PostgreSQL 参数。
 *   存在以下安全隐患:
 *     1. MySQL 危险参数 (allowLoadLocalInfile, autoDeserialize 等) 未覆盖
 *     2. H2 使用 ';' 分隔参数,完全绕过 '?' 检查
 *     3. MySQL multi-host 语法 '(host,param=val)' 和 address-block 语法不使用 '?'
 *
 *   修复方案: 对 URL 全文做 toLowerCase() + contains() 匹配,
 *   覆盖所有参数分隔符格式 (?, ;, (), address=),并扩展黑名单覆盖全部主流驱动。
 *
 * @Author taoYan
 * @Date 2022/8/10 18:15
 */
public cla

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key