Skip to content

Security Limits & Decoder API Enhancement#1

Merged
afshawnlotfi merged 2 commits intomasterfrom
feature/buffer-limits
Feb 27, 2026
Merged

Security Limits & Decoder API Enhancement#1
afshawnlotfi merged 2 commits intomasterfrom
feature/buffer-limits

Conversation

@afshawnlotfi
Copy link
Copy Markdown
Member

@afshawnlotfi afshawnlotfi commented Feb 27, 2026

Overview

This PR introduces security-focused parameter validation and enhances the vertex buffer decoding API for better flexibility and type safety.

Changes

1. Security Limits (MeshoptLimits class)

New limits.py module providing configurable security limits to prevent DoS attacks via memory exhaustion:

Configurable Limits:

Limit Default Value
MAX_TOTAL_BYTES 1 GB
MAX_VERTEX_SIZE 256 bytes
MAX_VERTEX_COUNT 100 million
MAX_INDEX_COUNT 500 million

Validation Methods:

  • validate_vertex_params() - Validates vertex count, vertex size, alignment (must be multiple of 4), and total allocation
  • validate_index_params() - Validates index count and index size (must be 2 or 4)

All encoder/decoder functions now validate parameters before memory allocation.

2. Enhanced decode_vertex_buffer() API

Added optional dtype parameter for direct decoding to custom numpy dtypes:

# Default behavior (float32 with auto-reshaping)
vertices = decode_vertex_buffer(count, size, buffer)

# Direct decoding to custom dtype
vertices = decode_vertex_buffer(count, size, buffer, dtype=my_custom_dtype)

This consolidates the previous decode_vertex_buffer_raw() function into the main API, reducing code duplication while maintaining backward compatibility.

Version

0.2.20a50.2.30a

- Implement validation methods for vertex and index parameters to prevent memory exhaustion and ensure valid inputs.
- Integrate MeshoptLimits in encoder and decoder functions to enforce limits during encoding and decoding processes.
@afshawnlotfi afshawnlotfi changed the title Feature/buffer limits Security Limits & Decoder API Enhancement Feb 27, 2026
@afshawnlotfi afshawnlotfi merged commit 1d33f81 into master Feb 27, 2026
10 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant