Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【v2.1.0】access_token访问漏洞 #9830

Closed
JavaAjust opened this issue Jan 10, 2023 · 4 comments
Closed

【v2.1.0】access_token访问漏洞 #9830

JavaAjust opened this issue Jan 10, 2023 · 4 comments
Labels
status/duplicate This issue or pull request already exists

Comments

@JavaAjust
Copy link

JavaAjust commented Jan 10, 2023

Describe the bug
A clear and concise description of what the bug is.
nacos.io/zh-cn/docs/auth.html 按照官网;docker启动进行了如下配置 NACOS_AUTH_ENABLE=true NACOS_AUTH_TOKEN=字符串

NACOS_AUTH_TOKEN并没有生效;还是继续用 默认的secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
使用jwt加密生成access_token,猜可以访问api接口

用自定义的NACOS_AUTH_TOKEN=字符串 生成的access_token访问不了

Expected behavior
A clear and concise description of what you expected to happen.
使用自定义的NACOS_AUTH_TOKEN;生成access_token能够访问api接口

Actually behavior
A clear and concise description of what you actually to happen.
还是需要使用 默认的secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789;生成access_token能够访问api接口

How to Reproduce
Steps to reproduce the behavior:
shell docker run --env PREFER_HOST_MODE=hostname --env MODE=standalone --env NACOS_AUTH_ENABLE=true --env NACOS_AUTH_TOKEN=SecretKey:e472c13e-a568-47cd-bb49-c15e253f62e9 -p 8848:8848 nacos/nacos-server:v2.1.0

Desktop (please complete the following information):

  • OS: [e.g. Centos]:centos
  • Version [e.g. nacos-server 1.3.1, nacos-client 1.3.1]:v2.1.0
  • Module [e.g. naming/config]
  • SDK [e.g. original, spring-cloud-alibaba-nacos, dubbo]

Additional context
Add any other context about the problem here.

public static String createToken(String userName) throws IOException {
        long now = System.currentTimeMillis();

        Date validity;

        validity = new Date(now + 18000 * 1000L);

        String raw_key = "SecretKey012345678901234567890123456789012345678901234567890123456789";
        String raw_key222 = "SecretKey:e472c13e-a568-47cd-bb49-c15e253f62e9";
        byte[] key_byte = new BASE64Decoder().decodeBuffer(raw_key);

        Claims claims = Jwts.claims().setSubject(userName);
        return Jwts.builder().setClaims(claims).setExpiration(validity)
                .signWith(Keys.hmacShaKeyFor(key_byte), SignatureAlgorithm.HS256).compact();

    public static void main(String[] args) throws IOException {
            String token = createToken("nacos");
            System.out.println(token);
        }
    }
`

使用生成的access_token访问

http://10.132.9.106:8848/nacos/v1/cs/configs?pageNo=1&pageSize=10&search=accurate&accessToken=eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJuYWNvcyIsImV4cCI6MTY3MzM0MzA3OX0.7VB3vDekfKEItOMf-0CuMxpvGr43u15KyfwOgIKi1yg&username=nacos
@YunWZ
Copy link
Contributor

YunWZ commented Jan 10, 2023

PRs welcome.

@JavaAjust JavaAjust changed the title access_token访问漏洞 【v2.1.0】access_token访问漏洞 Jan 11, 2023
@KomachiSion
Copy link
Collaborator

Maybe Fixed in 2.2.0 with #9380

@PRANRAVEE
Copy link

PRANRAVEE commented Jan 19, 2023 via email

@KomachiSion KomachiSion added status/duplicate This issue or pull request already exists and removed status/need feedback labels Jan 28, 2023
@KomachiSion
Copy link
Collaborator

KomachiSion commented Feb 21, 2023

鉴于持续有人问这个issue的问题,

在这里说明下, 这个不是漏洞~, 不是漏洞~ , 不是漏洞~

我使用nacos2.1.0版本在本地启动, 只在token.key后面添加一个'a'字符,开启鉴权后启动测试, 返回接口为403错误 invalid token。

image

。关于pr fixed是另一个使用问题, 部分token,key会导致生成token失败,导致登录失败。对应pr有说明。

至于本issue提交的漏洞,大概率是用户自己的环境有问题,导致配置未生效。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

4 participants