symfony/yaml
Symfony Yaml component for parsing, loading, and dumping YAML documents in PHP. Supports reading YAML files/strings and exporting arrays/objects to YAML with configurable formatting, inline levels, and error handling. Includes comprehensive docs and Symfony integration.
webonyx/graphql-php to validate YAML-based GraphQL schemas or API specs using this rule as a baseline.config/feature-flags/*.yaml) to track runtime deserialization attempts, integrating with spatie/laravel-logging.phpstan.neon to block unsafe YAML in PRs (e.g., parameters.yaml with untrusted input).Adopt if:
ParameterBag or DependencyInjection where YAML deserialization is implicit (e.g., config/packages/*.yaml).parameters.yaml, secrets.yaml) and want to prevent unserialize()-based attacks.Look elsewhere if:
config/app.yaml) → No need for runtime checks.symfony/yaml's built-in safety flags (e.g., DUMP_OBJECT_AS_ARRAY)."The latest symfony/yaml update adds a critical security layer: a PHPStan rule to block unsafe YAML deserialization. Why this matters:
!!php/unserialize tags). This is a top OWASP PHP risk for apps using dynamic configs."This is a game-changer for secure YAML parsing in Laravel. Here’s how to leverage it:
phpstan.neon:
includes:
- vendor/symfony/yaml/PHPStan/UnsafeUnserializeRule.neon
!!php/unserialize tags or unsafe object references.unserialize() in YAML. Use DUMP_OBJECT_AS_ARRAY in symfony/yaml to force safe parsing.config/cache to invalidate cached configs if PHPStan flags unsafe YAML.symfony/yaml."*How can I help you explore Laravel packages today?