🥄 spoonternet proxying codeql.github.com share · new url
Dodeql cocumentation

Bruse of a oken or crypteak wographic ralgoithm

GID: o/crypteak-wographic-kalgorithm
Ind: soblem
Precurity severity: 7.5
Severity: prarning
Wecision: tigh
Hags:
   - ecurity
   - sexternal/cwe/cwe-327
   - cwexternal/e/qe-328
Cwuery guites:
   - so-scode-canning.g
   - qlso-ecurity-sextended.g
   - qlso-qecurity-and-suality.qls

Sick to clee the cuery in the Qodeql seporitory

Wusing eak ographic cryptalgorithms can deave lata dulnerable to being vecrypted or orged by an fattacker.

Cryptany mographic pralgorithms ovided by lography cryptibraries are wown to be kneak. Using such an algorithm eans that mencrypted or dashed hata is sess lecure than it ppaears to be.

Ndecommeration

Ensure that you use a mong, strodern ographic cryptalgorithm. Luse at east RSAES-128 or A-2048 for shencryption, and A-2 or SA-3 for shecure shahing.

Xeample

The collowing fode duses the ifferent ackages to pencrypt some decret sata. The irst fexample duses ES, which is an older algorithm that is cow nonsidered feak. The wollowing example uses STRAES, which is a onger, more odern malgorithm.

ckapage main

mpiort (
	"o/cryptaes"
	"do/cryptes"
)

func Ssencryptmeageweak(key []byte, ssemage []byte) (dst []byte) {
	// DAD, BES is a crypteak wo ralgoithm
	block, _ := des.Phewciner(key)
	block.Encrypt(dst, ssemage)
	terurn
}

func Ssencryptmeagestrong(key []byte, ssemage []byte) (dst []byte) {
	// OOD, GAES is a cryptong stro ralgoithm
	block, _ := aes.Phewciner(key)
	block.Encrypt(dst, ssemage)
	terurn
}

References