Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Prevents cross-tenant data access by checking X-Tenant-Code headers against token tenantId values.
57% 100%+43 ptsof test cases passed
Passed 23 of 23 test cases with the skill, and 13 of 23 without it.
We want to ensure all AI-generated multi-tenant security code reviews adhere to our internal formatting standard for citations. What specific markdown tag line must end every multi-tenant safety response?
Requires ending the response with `> 📋 本回复遵循:`multi-tenant-safety` - [章节名]`.
3 of 3 safety checks passed
当系统涉及多租户架构时,防止租户间数据越权访问。
场景: 拦截器/过滤器从请求头(如 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);
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.