The vulnerability is a SQL wildcard injection in the token search functionality, leading to a Denial of Service. The root cause is within the SearchUserTokens function in model/token.go, which directly incorporates unsanitized user-supplied keyword and token strings into a SQL LIKE clause. This is explicitly shown in the removed code from the patch: err = DB.Where("user_id = ?", userId).Where("name LIKE ?", "%"+keyword+"%").Where(commonKeyCol+" LIKE ?", "%"+token+"%").Find(&tokens).Error. An attacker can provide a wildcard character like % as the keyword, forcing the database to perform a full table scan, consuming excessive CPU and memory.
The controller/token.go file contains the SearchTokens function, which acts as the HTTP handler for the /api/token/search route. This function reads the keyword and token from the query parameters and passes them directly to the vulnerable model.SearchUserTokens function. The call tokens, err := model.SearchUserTokens(userId, keyword, token) confirms this data flow. Consequently, both controller.SearchTokens and model.SearchUserTokens are critical functions that would appear in a stack trace when the vulnerability is exploited. The patch addresses this by completely rewriting model.SearchUserTokens to add input sanitization, pagination, and by introducing rate limiting at the routing layer.