Loading skill
Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Checks multi-tenant code for isolation flaws, such as spoofable tenant headers, that allow cross-tenant data access.
77% 100%+23 ptsof test cases passed
Passed 22 of 22 test cases with the skill, and 17 of 22 without it.
3 of 3 safety checks passed
Not used yet
当系统涉及多租户架构时,防止租户间数据越权访问。
场景: 拦截器/过滤器从请求头(如 X-Tenant-Code)设置租户上下文,但未与认证 token 中的 tenantId 做一致性校验
请求头可以被客户端任意伪造。如果后端只信任请求头中的租户标识,攻击者只需修改 header 就能访问其他租户的数据。
// ❌ 错误: 只信任请求头,未校验 token
@Override
public boolean preHandle(HttpServletRequest request, ...) {
String tenantCode = request.getHeader("X-Tenant-Code");
TenantMiniAppConfig config = configRepository.findByTenantCode(tenantCode);
TenantContext.setTenantId(config.getTenantId()); // 直接信任 header
return true;
}
// 攻击者拿着 tenantId=1 的 token,配上 X-Tenant-Code: OTHER_TENANT
// 就能读到其他租户的数据
// ✅ 正确: header 只做路由定位,必须与 token tenantId 校验一致
@Override
public boolean preHandle(HttpServletRequest request, ...) {
String tenantCode = request.getHeader("X-Tenant-Code");
TenantMiniAppConfig config = configRepository.findByTenantCode(tenantCode);
// 从认证 token 中取出 tenantId(真相源)
Long tokenTenantId = (Long) request.getAttribute("tokenTenantId");
Published skills whose descriptions closely match this one, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.