Kerberos Keytab Readable by Others
Checks the owner and permissions of the system Kerberos keytab.
- Why It Matters
- A keytab holds long-term keys, so anyone who can read it can act as the host.
- How It Detects
- Reads the metadata of /etc/krb5.keytab, never its contents. It fails when root does not own the file or when group or others have any access. It skips the check when the file does not exist.
- How to Fix
- Run chown root:root /etc/krb5.keytab and chmod 600 /etc/krb5.keytab. Replace the keys if unknown accounts may have read the file.
- How to Verify
stat -c '%a %U' /etc/krb5.keytab should print 600 root.- CVSS v3.1 Vector
CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N- Control Category
- Access Control: CIS Controls v8 3, 6; NIST CSF 2.0 PR.AA, PR.DS
- Fix Effort
- Low
- CIS Controls v8 Safeguard
- 3.3
- NIST CSF 2.0 Subcategory
- PR.AA-05, PR.DS-01
- CWE
- CWE-732
- NIST SP 800-53 Rev. 5
- AC-6, IA-5
- References
- MIT Kerberos, krb5.conf
Source Code
The complete file that defines this check. Run it with openvapt scan --only HOST-KRB-002, or read it offline with openvapt explain HOST-KRB-002.
internal/checks/host/kerberos.go · Lines 1-132View on GitHub at This Commit
| 1 | package host |
| 2 | |
| 3 | import ( |
| 4 | "context" |
| 5 | "fmt" |
| 6 | "regexp" |
| 7 | "sort" |
| 8 | "strings" |
| 9 | |
| 10 | "github.com/openvapt/openvapt/internal/check" |
| 11 | "github.com/openvapt/openvapt/internal/sys" |
| 12 | ) |
| 13 | |
| 14 | var ( |
| 15 | krbRef = check.Ref{Title: "MIT Kerberos, krb5.conf", URL: "https://web.mit.edu/kerberos/krb5-latest/doc/admin/conf_files/krb5_conf.html"} |
| 16 | krbWeakFlag = regexp.MustCompile(`(?i)^allow_weak_crypto\s*=\s*(true|yes|on|y|t|1)\b`) |
| 17 | krbEnctypes = regexp.MustCompile(`(?i)^(default_tkt_enctypes|default_tgs_enctypes|permitted_enctypes)\s*=\s*(.*)$`) |
| 18 | krbWeakType = regexp.MustCompile(`(?i)^(des|des3|rc4|arcfour)([a-z0-9-]*)$`) |
| 19 | ) |
| 20 | |
| 21 | // krbConfig reads krb5.conf and the files it includes, one level deep and at |
| 22 | // most 50 files, because distributions keep crypto policy in included files. |
| 23 | func krbConfig(ctx context.Context, s sys.System) (files map[string]string, complete, ok bool) { |
| 24 | r, e := s.ReadFile(ctx, "/etc/krb5.conf") |
| 25 | if e != nil { |
| 26 | return nil, true, false |
| 27 | } |
| 28 | files = map[string]string{"/etc/krb5.conf": string(r.Data)} |
| 29 | complete = r.Complete |
| 30 | var more []string |
| 31 | for _, line := range strings.Split(string(r.Data), "\n") { |
| 32 | f := strings.Fields(line) |
| 33 | if len(f) != 2 || !strings.HasPrefix(f[1], "/") { |
| 34 | continue |
| 35 | } |
| 36 | switch f[0] { |
| 37 | case "include": |
| 38 | more = append(more, f[1]) |
| 39 | case "includedir": |
| 40 | g, _ := s.Glob(strings.TrimRight(f[1], "/") + "/*") |
| 41 | more = append(more, g...) |
| 42 | } |
| 43 | } |
| 44 | sort.Strings(more) |
| 45 | if len(more) > 50 { |
| 46 | more, complete = more[:50], false |
| 47 | } |
| 48 | for _, p := range more { |
| 49 | x, e := s.ReadFile(ctx, p) |
| 50 | if e != nil || !x.Complete { |
| 51 | complete = false |
| 52 | continue |
| 53 | } |
| 54 | files[p] = string(x.Data) |
| 55 | } |
| 56 | return files, complete, true |
| 57 | } |
| 58 | |
| 59 | // krbListsWeak reads an enctype list. A leading minus removes a type, so it |
| 60 | // is not a weakness. |
| 61 | func krbListsWeak(list string) bool { |
| 62 | for _, t := range strings.FieldsFunc(list, func(c rune) bool { return c == ' ' || c == ',' || c == '\t' }) { |
| 63 | if krbWeakType.MatchString(strings.TrimPrefix(t, "+")) { |
| 64 | return true |
| 65 | } |
| 66 | } |
| 67 | return false |
| 68 | } |
| 69 | |
| 70 | func init() { |
| 71 | check.Register(&check.Check{ |
| 72 | ID: "HOST-KRB-001", Title: "Kerberos Allows Weak Encryption", Domain: check.DomainHost, |
| 73 | Severity: check.Medium, Category: check.CatCrypto, Effort: check.EffortLow, |
| 74 | CVSS: "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N", |
| 75 | Summary: "Checks the Kerberos client configuration for weak encryption types.", |
| 76 | Rationale: "DES and RC4 tickets can be cracked offline, which can reveal account passwords.", |
| 77 | Detection: "Reads /etc/krb5.conf and the files it includes, and looks for allow_weak_crypto set to true, or a DES, 3DES or RC4 type in an encryption type list. It skips the check when the file does not exist.", |
| 78 | Fix: "Remove allow_weak_crypto and list only AES types, for example aes256-cts-hmac-sha1-96, after confirming your Kerberos servers support them.", |
| 79 | Verify: "grep -E 'allow_weak_crypto|enctypes' /etc/krb5.conf should show no DES, 3DES or RC4 type.", |
| 80 | Refs: []check.Ref{krbRef}, |
| 81 | Standards: check.Standards{CWE: []string{"CWE-327"}, OWASP: []string{"A02:2021"}, NIST: []string{"SC-13", "IA-5"}}, |
| 82 | Run: func(ctx context.Context, s sys.System) []check.Result { |
| 83 | files, complete, ok := krbConfig(ctx, s) |
| 84 | if !ok { |
| 85 | return []check.Result{check.SkipR("/etc/krb5.conf", "Kerberos client configuration not found")} |
| 86 | } |
| 87 | var out []check.Result |
| 88 | for path, text := range files { |
| 89 | for _, line := range strings.Split(text, "\n") { |
| 90 | t := strings.TrimSpace(line) |
| 91 | if t == "" || t[0] == '#' || t[0] == ';' { |
| 92 | continue |
| 93 | } |
| 94 | if krbWeakFlag.MatchString(t) { |
| 95 | out = append(out, check.FailR(path, "allow_weak_crypto is enabled")) |
| 96 | } else if m := krbEnctypes.FindStringSubmatch(t); m != nil && krbListsWeak(m[2]) { |
| 97 | out = append(out, check.FailR(path, fmt.Sprintf("%s lists a weak type", m[1]))) |
| 98 | } |
| 99 | } |
| 100 | } |
| 101 | if !complete { |
| 102 | out = append(out, check.IncompleteR("/etc/krb5.conf", "Some Kerberos configuration could not be read")) |
| 103 | } |
| 104 | if len(out) == 0 { |
| 105 | return []check.Result{check.PassR("/etc/krb5.conf", "No weak encryption type is configured")} |
| 106 | } |
| 107 | return out |
| 108 | }, |
| 109 | }) |
| 110 | check.Register(&check.Check{ |
| 111 | ID: "HOST-KRB-002", Title: "Kerberos Keytab Readable by Others", Domain: check.DomainHost, |
| 112 | Severity: check.Medium, Category: check.CatAccess, Effort: check.EffortLow, |
| 113 | CVSS: "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:N/A:N", |
| 114 | Summary: "Checks the owner and permissions of the system Kerberos keytab.", |
| 115 | Rationale: "A keytab holds long-term keys, so anyone who can read it can act as the host.", |
| 116 | Detection: "Reads the metadata of /etc/krb5.keytab, never its contents. It fails when root does not own the file or when group or others have any access. It skips the check when the file does not exist.", |
| 117 | Fix: "Run chown root:root /etc/krb5.keytab and chmod 600 /etc/krb5.keytab. Replace the keys if unknown accounts may have read the file.", |
| 118 | Verify: "stat -c '%a %U' /etc/krb5.keytab should print 600 root.", |
| 119 | Refs: []check.Ref{krbRef}, |
| 120 | Standards: check.Standards{CWE: []string{"CWE-732"}, NIST: []string{"AC-6", "IA-5"}}, |
| 121 | Run: func(_ context.Context, s sys.System) []check.Result { |
| 122 | fi, e := s.Stat("/etc/krb5.keytab") |
| 123 | if e != nil { |
| 124 | return []check.Result{check.SkipR("/etc/krb5.keytab", "No system keytab found")} |
| 125 | } |
| 126 | if fi.UID != 0 || fi.Mode.Perm()&0o077 != 0 { |
| 127 | return []check.Result{check.FailR("/etc/krb5.keytab", fmt.Sprintf("Mode %o, owner uid %d", fi.Mode.Perm(), fi.UID))} |
| 128 | } |
| 129 | return []check.Result{check.PassR("/etc/krb5.keytab", "Owned by root, with no group or other access")} |
| 130 | }, |
| 131 | }) |
| 132 | } |
Also available as plain Markdown for notes, scripts and AI tools. Same facts, same source, no styling.
Cite This Page
If this page helped your work, please cite it. The version and web address are filled in; the access date is today's date in your browser. Every other style, and when credit is required, is on How to Cite OpenVAPT.
OpenVAPT. (2026). HOST-KRB-002 Kerberos Keytab Readable by Others (Version 0.2.0-alpha.1). OpenVAPT Check Catalogue. Retrieved November 4, 2026, from https://openvapt.com/checks/HOST-KRB-002.html
In text: (OpenVAPT, 2026). Accessed: the date shown is today's date from your own browser (the site's build date without JavaScript); change it to the day you read the page.
@misc{openvapt_host_krb_002,
author = {{OpenVAPT}},
title = {{HOST-KRB-002 Kerberos Keytab Readable by Others}},
year = {2026},
howpublished = {\url{https://openvapt.com/checks/HOST-KRB-002.html}},
note = {OpenVAPT Check Catalogue, version 0.2.0-alpha.1. Accessed 4 November 2026}
}
Accessed: the date shown is today's date from your own browser (the site's build date without JavaScript); change it to the day you read the page.
Citing OpenVAPT does not mean OpenVAPT endorses, approves or has reviewed your work.