前端时间完全部门发现我们的nacos 平台有漏洞,可以查看用户信息和随意添加用户
- 漏洞复现:http://localhost:8848/nacos/v1/auth/users?pageNo=1&pageSize=100
2.漏洞复现添加用户:
http://127.0.0.1:8848/nacos/v1/auth/users?username=test&password=test
User-Agent:Nacos-Server 该参数为nacos 白名单数据。
出现上面的原因是因为没有开启nacos 的权限认证 (nacos.core.auth.enabled=false)
需要需改为:
### 开启鉴权
nacos.core.auth.enabled=true
### 关闭使用user-agent判断服务端请求并放行鉴权的功能
nacos.core.auth.enable.userAgentAuthWhite=false
### 配置自定义身份识别的key(不可为空)和value(不可为空)
nacos.core.auth.server.identity.key=example
nacos.core.auth.server.identity.value=example
Nacos 配置参数说明:
### 默认Web上下文路径
server.servlet.contextPath=/nacos
### 默认Web服务器端口
server.port=8848
#*************** Network Related Configurations ***************#
### 是否在cluster.conf中使用主机名而不是IP作为Nacos服务器地址
# nacos.inetutils.prefer-hostname-over-ip=false
### 指定本地服务器的IP:
# nacos.inetutils.ip-address=
#*************** Config Module Related Configurations ***************#
### 是否将用户MySQL作为数据源
# spring.datasource.platform=mysql
### 数据库数量
# db.num=1
### 数据库连接URL:
# db.url.0=jdbc:mysql://1.1.1.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
# db.user=user
# db.password=password
#*************** 命名模块相关配置 ***************#
### 数据调度任务执行周期(以毫秒为单位)
# nacos.naming.distro.taskDispatchPeriod=200
### 批处理同步任务的数据计数
# nacos.naming.distro.batchSyncKeyCount=1000
### 如果同步任务失败,则重试延迟(以毫秒为单位)
# nacos.naming.distro.syncRetryDelay=5000
### 是否启用数据预热。如果设置为false,则服务器将接受请求而无需本地数据准备
# nacos.naming.data.warmup=true
### 如果启用实例自动过期,则类似于实例的运行状况检查
# nacos.naming.expireInstance=true
### 如果启用空服务自动清除,则会自动清除具有空实例的服务
nacos.naming.empty-service.auto-clean=false
### 空服务清除任务会延迟启动时间(以毫秒为单位)
nacos.naming.empty-service.clean.initial-delay-ms=60000
### 空服务清理任务周期执行时间(以毫秒为单位)
nacos.naming.empty-service.clean.period-time-ms=20000
#*************** CMDB Module Related Configurations ***************#
### 转储外部CMDB的时间间隔(以秒为单位)
# nacos.cmdb.dumpTaskInterval=3600
### 轮询数据更改事件的时间间隔,以秒为单位
# nacos.cmdb.eventTaskInterval=10
### 加载标签的时间间隔(以秒为单位)
# nacos.cmdb.labelTaskInterval=300
### 是否打开数据加载任务
# nacos.cmdb.loadDataAtStart=false
### Add in 2.0.0 gjp
### The interval to clean empty service, unit: milliseconds.
nacos.naming.clean.empty-service.interval=60000
### The expired time to clean empty service, unit: milliseconds.
nacos.naming.clean.empty-service.expired-time=60000
### The interval to clean expired metadata, unit: milliseconds.
nacos.naming.clean.expired-metadata.interval=5000
### The expired time to clean metadata, unit: milliseconds.
nacos.naming.clean.expired-metadata.expired-time=60000
### The delay time before push task to execute from service changed, unit: milliseconds.
nacos.naming.push.pushTaskDelay=500
### The timeout for push task execute, unit: milliseconds.
nacos.naming.push.pushTaskTimeout=5000
### The delay time for retrying failed push task, unit: milliseconds.
nacos.naming.push.pushTaskRetryDelay=1000
### Since 2.0.3 gjp
### The expired time for inactive client, unit: milliseconds.
nacos.naming.client.expired.time=180000