Scala Jwt Without Proper Sign
Description
Detects unsafe JWT token signing practices in Scala applications where tokens are created without proper cryptographic signing. Unsigned or improperly signed JWTs can be tampered with by attackers, potentially allowing unauthorized access or privilege escalation.
Detection Strategy
• Identifies calls to the 'compact' method on JWT builder instances
• Checks if the JWT builder instance was configured without proper signing mechanisms
• Reports a vulnerability when a JWT token is generated (via compact()) without proper cryptographic signatures
Vulnerable code example
import io.jsonwebtoken.Jwts
class JwtExample {
def createInsecureToken(): String = {
// Vulnerable: JWT token created without signature/secret key
Jwts.builder()
.setSubject("user")
.compact()...✅ Secure code example
import io.jsonwebtoken.Jwts
import io.jsonwebtoken.SignatureAlgorithm
import javax.crypto.spec.SecretKeySpec
import java.util.Base64
class JwtExample {
private val secretKey = generateSecretKey() // Store securely, don't hardcode
...Search for vulnerabilities in your apps for free with Fluid Attacks' automated security testing! Start your 21-day free trial and discover the benefits of the Continuous Hacking Essential plan. If you prefer the Advanced plan, which includes the expertise of Fluid Attacks' hacking team, fill out this contact form.