Go Deprecated Encryption Function Use

Description

This vulnerability detector identifies usage of deprecated RSA encryption functions in Go code that use the insecure PKCS#1 v1.5 padding scheme. These functions are vulnerable to padding oracle attacks and have been superseded by more secure alternatives using OAEP padding.

Weakness:

052 - Insecure encryption algorithm

Category: Information Collection

Detection Strategy

    Scans Go source code files that import the 'crypto/rsa' package

    Identifies function calls to deprecated RSA encryption methods: EncryptPKCS1v15, DecryptPKCS1v15, and DecryptPKCS1v15SessionKey

    Reports vulnerabilities when any of these deprecated PKCS#1 v1.5 functions are called, regardless of how the crypto/rsa package is aliased in the import statement

    Triggers on direct function calls using the RSA package alias (e.g., 'rsa.EncryptPKCS1v15()' or custom alias like 'cryptorsa.EncryptPKCS1v15()')

Vulnerable code example

package main

import (
	"crypto/rand"
	"crypto/rsa"
)

func UnsafeEncrypt(pub *rsa.PublicKey, msg []byte) ([]byte, error) {...

✅ Secure code example

package main

import (
	"crypto/rand"
	"crypto/rsa"
	"crypto/sha256"
)
...