Skip to content

Security: HypothesisPHP/Mappers

Security

SECURITY.md

Security Policy

Supported Versions

Version Supported
1.x
< 1.0

Reporting a Vulnerability

Do not open a public GitHub issue for security vulnerabilities.

Please report security issues privately via:

What to Include

  • Description of the vulnerability
  • Steps to reproduce
  • Affected versions
  • Potential impact assessment
  • Suggested fix (if any)

Response Timeline

Step Timeline
Acknowledgement Within 48h
Initial assessment Within 5 days
Fix or mitigation developed Within 14 days
Public disclosure After fix released

Security Considerations

Input Validation

Mappers processes untrusted data (API payloads, user input). Key considerations:

  • Type coercion — ScalarCaster performs type coercion. Values outside expected ranges throw CastingException, never silently truncate.
  • JSON decodingJsonMappingException is thrown on malformed JSON; the library never swallows parse errors.
  • Reflection access — Mappers uses ReflectionProperty::setAccessible(true) to write private/protected properties. This is intentional and documented. Do not map untrusted classes with destructive side effects in setters.
  • Class instantiationArrayToObjectMapper instantiates classes by name. Never pass user-controlled class names as the $target parameter.
  • Circular references — Protected by MappingContext reference tracking. The #[MaxDepth] attribute limits recursion depth.

What Mappers Does NOT Do

  • Does not execute arbitrary code from mapped data
  • Does not call eval() or dynamic code generation
  • Does not make network requests
  • Does not access the filesystem
  • Does not log sensitive data

Recommended Practices

// SAFE: class name is hardcoded
$dto = $mappers->map($request->all(), UserDto::class);

// UNSAFE: never pass user-controlled class names
$class = $request->get('target_class'); // attacker-controlled
$dto = $mappers->map($data, $class);    // DO NOT DO THIS
// Use groups to prevent over-exposure of sensitive fields
$context = $mappers->context(['public']);
$array   = $mappers->toArray($user, $context); // password excluded

There aren't any published security advisories