Skip to content

Commit b6be1eb

Browse files
authored
[release/0.3] Use SHA256 to digest the seccomp profile (#530)
The MD5 hash algorithm panics under GODEBUG=fips140=only. Calculate the digest of the seccomp profile using SHA256 instead. The message containing the digest is informational only so changing the hash algorithm should not introduce any compatibility breaks. And as far as I can tell the DockerOpt.msg field is a dead store so this change should have no observable impact on behaviour aside from not panicking when run in FIPS140-only mode. Signed-off-by: Cory Snider <csnider@mirantis.com> (cherry picked from commit e91fb78) Signed-off-by: Cory Snider <csnider@mirantis.com>
1 parent d9e8816 commit b6be1eb

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

core/security_context.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package core
1818

1919
import (
2020
"bytes"
21-
"crypto/md5"
21+
"crypto/sha256"
2222
"encoding/json"
2323
"fmt"
2424
"os"
@@ -283,8 +283,8 @@ func getSeccompDockerOpts(seccomp *runtimeapi.SecurityProfile) ([]DockerOpt, err
283283
if err := json.Compact(b, file); err != nil {
284284
return nil, err
285285
}
286-
// Rather than the full profile, just put the filename & md5sum in the event log.
287-
msg := fmt.Sprintf("%s(md5:%x)", fname, md5.Sum(file))
286+
// Rather than the full profile, just put the filename & digest in the event log.
287+
msg := fmt.Sprintf("%s(sha256:%x)", fname, sha256.Sum256(file))
288288

289289
return []DockerOpt{{"seccomp", b.String(), msg}}, nil
290290
}

0 commit comments

Comments
 (0)