Skip to content

TOB-K8S-017: Use standard formats everywhere  #81140

@cji

Description

@cji

This issue was reported in the Kubernetes Security Audit Report

Description
Kubernetes supports multiple backends for authentication and authorization, one of which is the Attribute-Based Access Control (ABAC) backend. This backend uses a format consisting of a single-line JSON object on each line.

for scanner.Scan() {
    i++ 
    p := &abac.Policy{}
    b := scanner.Bytes()

    // skip comment lines and blank lines
    trimmed := strings.TrimSpace(string(b))
    if len(trimmed) == 0 || strings.HasPrefix(trimmed, "#") {
       continue
    }   

    decodedObj, _, err := decoder.Decode(b, nil, nil)
    ...

Figure 31.1: A portion of NewFromFile - kubernetes-1.13.4/pkg/auth/authorizer/abac/abac.go

This line-delimited format leads to two main issues:

The format is prone to human error. Forcing JSON objects into a single line increases the difficulty of audits and the need for specialized tooling.
JSON objects are arbitrarily restricted to the size of Scanner tokens, or about 65k characters as of this report.

From a more systemic perspective, the use of various formats across the system (JSON, YAML, line-delimited, etc) leads to increased surface area for parsing vulnerabilities.

Recommendation
Short term, improve the semantics of ABAC configuration file parsing.

Long term, consider consolidating the use of multiple configuration file formats, and preventing arbitrary formats from being introduced into the system.

Anything else we need to know?:

See #81146 for current status of all issues created from these findings.

The vendor gave this issue an ID of TOB-K8S-017 and it was finding 32 of the report.

The vendor considers this issue Informational Severity.

To view the original finding, begin on page 78 of the Kubernetes Security Review Report

Environment:

  • Kubernetes version: 1.13.4

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/securitykind/bugCategorizes issue or PR as related to a bug.lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.priority/awaiting-more-evidenceLowest priority. Possibly useful, but not yet enough support to actually get it done.sig/authCategorizes an issue or PR as relevant to SIG Auth.wg/security-auditCategorizes an issue or PR as relevant to WG Security Audit.

    Type

    No type

    Projects

    Status

    Needs KEP

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions