有缺陷的访问控制

有缺陷的访问控制

HijackSessionAssignment

1750833499093-7e3e7623-6692-4a9b-b013-3e4eb3e7be13.png

在 HijackSessionAuthenticationProvider 类中,ID 的生成由以下代码控制:

private static long id = new Random().nextLong() & Long.MAX_VALUE;
// ...
private static final Supplier<String> GENERATE_SESSION_ID = 
    () -> ++id + "-" + Instant.now().toEpochMilli();
  • 使用 Random().nextLong() 生成初始随机数,并通过 & Long.MAX_VALUE 确保为正数
  • 每次生成新 ID 时使用 ++id 递增
  • 附加当前时间的毫秒数(Instant.now().toEpochMilli())
@Override
  public Authentication authenticate(Authentication authentication) {
    if (authentication == null) {
      return AUTHENTICATION_SUPPLIER.get();
    }
 // 检查1:如果提供了ID且该ID在有效会话列表中
    if (StringUtils.isNotEmpty(authentication.getId())
        && sessions.contains(authentication.getId())) {
      authentication.setAuthenticated(true);
      return authentication;
    }
// 检查2:如果ID为空则生成新ID
    if (StringUtils.isEmpty(authentication.getId())) {
      authentication.setId(GENERATE_SESSION_ID.get());
    }

    authorizedUserAutoLogin();// 25%概率自动授权新会话

    return authentication;
  }

protected void authorizedUserAutoLogin() {
    if (!PROBABILITY_DOUBLE_PREDICATE.test(ThreadLocalRandom.current().nextDouble())) {
      Authentication authentication = AUTHENTICATION_SUPPLIER.get();
      authentication.setAuthenticated(true);
      addSession(authentication.getId());
    }
  }

总而言之,这道 题就是有百分之二十五的概率自动授权新对话,把它加入有效会话列表,而题目过关要求是输入的cookie值在有效会话列表中,所以根据会话id递增的规律,可以爆破解题。

先不设置cookie值,查看返回的cookie值

5307212479590026264-1750838353211

5307212479590026265-1750838369939

5307212479590026266-1750838383003

5307212479590026268-1750838396384

发现丢失了67号,所以以这个开始爆破

1750838876662-1815e073-aa4c-42e3-9648-ce1629d66227.png

不安全的直接对象引用

直接对象引用是指应用程序使用客户端提供的输入参数来访问数据或对象的一种设计方式。

如使用GET方法的直接对象引用通常表现为以下形式:

https://some.company.tld/dor?id=12345
https://some.company.tld/images?img=12345  
https://some.company.tld/dor/12345

IDORLogin

输入tom和cat就行

1750840114814-f307c059-5989-4ab0-b2c3-c4d8fbf0b8fe.png

这里利用hashmap的方式存储数据

IDORDiffAttributes

抓包获取属性列就行

1750839973541-e883a0c2-4528-4fe8-a62a-c6018acf971c.png

1750839959107-43f34771-2d74-475c-828e-0e4aa7111bb9.png

1750840243280-14b83ba2-5b22-468f-bab4-a32c2fe6cd67.png

1750840706484-bd3453d0-2b36-4d61-9358-c7f2b20aca76.png

IDORViewOwnProfile

1750840805824-35ea48f5-0ead-427f-808e-99efaaf59fe7.png

/IDOR/profile/{userId},userId可以由前面抓包的时候看到,也可以爆破

IDORViewOtherProfile

查看其他人的profile,根据id号爆破

1750841467933-70921df0-3bd0-48c0-8f8f-16d5f2fe5d9e.png

源码就是直接匹配了388这个id号

Missing Function Level Access Control

功能级访问控制缺失

MissingFunctionACHiddenMenus

隐藏的菜单项

1750921017660-17d22afd-69da-46e2-9000-261f8b03c949.png

MissingFunctionACYourHash

1750922266523-82ece1b3-6fbc-401e-9b50-63ef513cd64f.png

访问上题得到的/access-control/users路由,并添加Content-Type: application/json,返回hash数据

1750922492539-c360ce92-d923-4cf3-9022-07fddb925505.png

源码就是比对Jerry的Userhash

更新: 2025-06-28 18:38:46
原文: https://www.yuque.com/cindahy/aqfzwf/kpbgkpg5qt9m09ap

LICENSED UNDER CC BY-NC-SA 4.0
评论