Skip to content
New issue

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

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

Already on GitHub? # to your account

log-injection in middleware/jwt_refresh_token_middleware.go #1

Open
gtqbhksl opened this issue Aug 20, 2024 · 0 comments
Open

log-injection in middleware/jwt_refresh_token_middleware.go #1

gtqbhksl opened this issue Aug 20, 2024 · 0 comments

Comments

@gtqbhksl
Copy link

		header := ctx.GetHeader("Authorization")
		if header == "" {
			ctx.JSON(http.StatusUnauthorized, models.ResponseJson{
				Success: false,
				Message: "authorization is required",
			})
			ctx.Abort()
			return
		}

		parts := strings.Split(header, " ")
		fmt.Println(parts)

In line 28 of the middleware/jwt_refresh_token_middleware.go file, the program uses fmt.Println(parts) to print the split header (the value obtained from the Authorization header). This is a potential security risk because if the value is controlled by the user (which appears to be the case based on the code snippet provided), an attacker may attempt to inject malicious content in the header to perform a log injection attack. Using unverified or uncleaned user input during logging may lead to security issues such as sensitive information disclosure and tampering of log files. This situation is one of the common forms of log injection vulnerability. Therefore, you should not output unprocessed user input directly into the log file.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant