Summary
SiYuan kernel versions before 3.7.4 do not adequately restrict repeated API-token authentication attempts through the Authorization header or token query parameter. An unauthenticated remote attacker may automate token guesses, especially when a short or weak custom token is configured, and successful authentication can provide administrative access.
Affected context
The vulnerability occurs in the SiYuan kernel's CheckAuth() middleware when API-token authentication is enabled. Token-based requests through supported header or query-parameter paths are not covered by the application's CAPTCHA or lockout controls, allowing repeated authentication attempts under deployments that use guessable or insufficiently protected tokens.
Exploit preconditions
- Attack surface: Network-accessible SiYuan API authentication endpoints
- Required access: No prior authentication is required
- Trigger point: Repeated requests using an API token supplied through an Authorization header or token query parameter
- Why exploitation is possible: These authentication paths bypass attempt-counting, CAPTCHA, or lockout protections, allowing automated guessing to continue without effective throttling
- Additional condition: The configured API token must be sufficiently weak, short, exposed, or otherwise guessable for authentication to succeed
Why this happens
The middleware fails to apply consistent anti-automation controls to all API-token authentication paths. Authentication attempts supplied through the Authorization header or query parameter are accepted without being integrated with the application's failed-attempt tracking and lockout mechanisms. This maps to CWE-307: Improper Restriction of Excessive Authentication Attempts, because repeated guesses are not adequately limited or challenged.
Potential impact
- An attacker may obtain valid API-token authentication
- The attacker could gain RoleAdministrator-level access
- Arbitrary file operations may be performed
- SQL queries may be issued through administrative functionality
- Application data may be modified, disclosed, or deleted
- The SiYuan instance could be used as a foothold for further compromise
General mitigation guidance
Mitigation generally focuses on applying uniform abuse protections to every authentication path and reducing the value of guessed credentials.
Common defensive patterns include:
- Enforcing rate limits, progressive delays, CAPTCHA challenges, and lockouts for failed token attempts
- Applying the same controls to Authorization headers and query-parameter authentication
- Using long, randomly generated tokens managed through protected secret storage
- Avoiding tokens in URLs because query parameters may be recorded in logs, history, or monitoring systems
- Restricting administrative API exposure to trusted networks or authenticated gateways where practical
- Running the application with least-privilege filesystem and database permissions
- Monitoring and revoking tokens when unusual authentication activity is detected
How teams detect issues like this
Organizations can identify this weakness through:
- Static analysis and code review checks for authentication branches that bypass shared throttling or lockout logic
- Tests that verify failed-attempt controls apply consistently to headers, query parameters, and other credential transports
- Dynamic testing for unlimited repeated authentication failures without delay or challenge
- Policy checks requiring strong randomly generated secrets and prohibiting credentials in URLs
- Log monitoring for high-volume token failures, distributed guessing patterns, and successful authentication following repeated failures
- Automated security review tools that flag missing rate limits and inconsistent authentication enforcement

