Skip to content

Latest commit

 

History

History
49 lines (40 loc) · 4.4 KB

File metadata and controls

49 lines (40 loc) · 4.4 KB

Threat Model Analysis for google/flatbuffers

  • Description: An attacker crafts a malicious FlatBuffer message with manipulated offsets or sizes. When the application parses this message, it attempts to read or write data beyond the allocated buffer. This is achieved by providing oversized length fields or offsets pointing outside the buffer.
  • Impact: Memory corruption, application crash, potentially arbitrary code execution if the attacker can control the overflowed data.
  • Affected FlatBuffers Component: Deserialization/Parsing logic (generated code, runtime library). Specifically, code handling offsets and size calculations during buffer traversal.
  • Risk Severity: Critical
  • Mitigation Strategies:
    • Thoroughly review generated parsing code for potential buffer overflow vulnerabilities.
    • Implement input validation to check for reasonable sizes and offsets in the FlatBuffer data before parsing.
    • Use memory-safe programming languages and practices.
    • Employ Address Space Layout Randomization (ASLR) and Data Execution Prevention (DEP) at the OS level.
  • Description: An attacker crafts a FlatBuffer message with extremely large or negative integer values in fields like offsets or sizes. During parsing, arithmetic operations on these values can result in integer overflows or underflows, leading to incorrect memory access calculations.
  • Impact: Incorrect parsing, memory corruption, application crash, potential for exploitation if the overflow leads to controllable memory access.
  • Affected FlatBuffers Component: Deserialization/Parsing logic (generated code, runtime library). Specifically, integer arithmetic operations related to offsets and sizes.
  • Risk Severity: High
  • Mitigation Strategies:
    • Carefully review generated code for integer arithmetic, especially involving offsets and sizes.
    • Use safe integer arithmetic libraries or implement explicit checks for overflows/underflows before calculations.
    • Validate integer values in the FlatBuffer data against expected ranges based on the schema.
  • Description: If the application dynamically loads FlatBuffer schemas from an untrusted source, an attacker can inject a malicious schema. This schema could be designed to exploit parsing vulnerabilities or alter application behavior. The attacker might compromise the schema source or manipulate the loading process.
  • Impact: Code execution, data corruption, application compromise, depending on the malicious schema and how it's exploited.
  • Affected FlatBuffers Component: Schema loading mechanism (application code, schema parsing if schemas are parsed at runtime).
  • Risk Severity: High
  • Mitigation Strategies:
    • Avoid dynamic schema loading from untrusted sources if possible.
    • If dynamic loading is necessary, strictly validate and sanitize loaded schemas.
    • Use secure channels (HTTPS, signed schemas) and authentication for schema retrieval.
    • Prefer pre-compiled schemas embedded within the application.
  • Description: While FlatBuffers aims for zero-copy, manipulated offsets in a FlatBuffer message can cause the parsing code to attempt reading data outside the intended buffer boundaries. This is due to incorrect offset handling during zero-copy access.
  • Impact: Information disclosure (reading sensitive data from memory), application crash, potential for exploitation if out-of-bounds reads can be controlled.
  • Affected FlatBuffers Component: Deserialization/Parsing logic (generated code, runtime library). Offset handling during buffer access.
  • Risk Severity: High
  • Mitigation Strategies:
    • Robust input validation and schema validation to ensure offsets are within valid ranges.
    • Careful review of generated code and application logic to prevent incorrect offset calculations or usage.
    • Utilize memory-safe programming practices.
    • Employ memory sanitizers during development and testing to detect out-of-bounds reads.