avatar

cindahy

A text-focused Halo theme

  • 首页
  • 文章分类
  • 项目
  • 关于
Home 有缺陷的访问控制
文章

有缺陷的访问控制

Posted 2025-06-28 Updated 2025-08- 17
By Administrator
10~13 min read

HijackSessionAssignment

在 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号,所以以这个开始爆破

不安全的直接对象引用

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

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

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

IDORLogin

输入tom和cat就行

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

IDORDiffAttributes

抓包获取属性列就行

IDORViewOwnProfile

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

IDORViewOtherProfile

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

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

Missing Function Level Access Control

功能级访问控制缺失

MissingFunctionACHiddenMenus

隐藏的菜单项

image.png

MissingFunctionACYourHash

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

源码就是比对Jerry的Userhash

webgoat
webgoat
License:  CC BY 4.0
Share

Further Reading

Aug 4, 2025

XXE

XML实体 XML实体(Entity)是XML中用来定义可重用内容的机制,当XML文档被解析时,这些实体引用会被替换为实际内容。实体主要有三种类型: 内部实体:在文档内部定义的实体(是否开启根元素的约束)(#PCDATA) <!DOCTYPE example [ <!ENTITY js "Jo

Jun 28, 2025

有缺陷的访问控制

HijackSessionAssignment 在 HijackSessionAuthenticationProvider 类中,ID 的生成由以下代码控制: private static long id = new Random().nextLong() & Long.MAX_VALUE; //

Jun 24, 2025

XSS(跨站脚本攻击)

基本概念 XSS是一种将恶意脚本注入到其他用户浏览的网页中的攻击方式 分类 反射型 非持久化攻击 典型场景 恶意URL:http://example.com/search?q=<script>alert(1)</script> 当用户点击该链接时,服务器返回的页面中包含未转义的搜索词,导致脚本执行

OLDER

XSS(跨站脚本攻击)

NEWER

第38天反序列化JAVA

Recently Updated

  • 常见安全产品整理(防火墙,WAF,EDR)
  • ELK从入门到实践
  • bp+mumu模拟器app抓包
  • xray漏扫工具
  • Java反序列化-RMI的几种攻击方式

Trending Tags

安全运营 文件上传 php反序列化 xss csrf ssrf xxe sql php 白帽子讲web安全

Contents

©2025 cindahy. Some rights reserved.

Using the Halo theme Chirpy