Skip to content

Validate class, namespace and attributes in PHP::objectToString() - #86

Open
Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-php
Open

Validate class, namespace and attributes in PHP::objectToString()#86
Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-php

Conversation

@Hackwar

@Hackwar Hackwar commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

When calling Registry::toString('PHP', ['class' => '<classname>', 'namespace' => '\\Name\\Space']) on a registry object, the PHP formatter is called and creates a string with a PHP class in it. For the class name and the namespace name, it uses the options here and for the attribute names it uses the keys in the registry object. All of these can be almost arbitrary strings and when writing it out as a PHP class, they are not validated. So in a hypothetical scenario, you could set the class option to Test {static function run() {/**arbitrary code**/}} Test::run(); class SomethingElse and that would inject code into this class. While the scenario is pretty complex, this PR still fixes it. It ensures that classes, attributes and namespaces only contain valid characters.

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