Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to specify the allowed "php" wrapper types #490

Closed
wants to merge 10 commits into from

Conversation

cgzones
Copy link
Contributor

@cgzones cgzones commented May 27, 2024

In addition of the current possibility to filter wrappers by their protocol name, also add the option to filter the "php" wrapper by the requested kind.
Especially the filter backend can be disabled that way.

See https://www.php.net/manual/en/wrappers.php.php and https://github.com/ambionics/cnext-exploits.

Please GCC:

    In file included from /usr/include/php/20220829/Zend/zend.h:30,
                     from /usr/include/php/20220829/main/php.h:31,
                     from /usr/include/php/20220829/main/SAPI.h:20,
                     from src/php_snuffleupagus.h:37,
                     from src/sp_ifilter.c:1:
    src/sp_pcre_compat.h: In function 'sp_regexp_compile':
    src/sp_pcre_compat.h:38:36: warning: '__zend_calloc' sizes specified with 'sizeof' in the earlier argument and not in the later argument [-Wcalloc-transposed-args]
       38 |   sp_regexp *ret = pecalloc(sizeof(sp_regexp), 1, 1);
          |                                    ^~~~~~~~~
    /usr/include/php/20220829/Zend/zend_alloc.h:199:72: note: in definition of macro 'pecalloc'
      199 | #define pecalloc(nmemb, size, persistent) ((persistent)?__zend_calloc((nmemb), (size)):ecalloc((nmemb), (size)))
          |                                                                        ^~~~~
    src/sp_pcre_compat.h:38:36: note: earlier argument should specify number of elements, later size of each element
       38 |   sp_regexp *ret = pecalloc(sizeof(sp_regexp), 1, 1);
          |                                    ^~~~~~~~~
    /usr/include/php/20220829/Zend/zend_alloc.h:199:72: note: in definition of macro 'pecalloc'
      199 | #define pecalloc(nmemb, size, persistent) ((persistent)?__zend_calloc((nmemb), (size)):ecalloc((nmemb), (size)))
          |                                                                        ^~~~~
Avoid the configure step each time during development.
In addition of the current possibility to filter wrappers by their
protocol name, also add the option to filter the "php" wrapper by the
requested kind.
Especially the 'filter' backend can be disabled that way.
doc/source/config.rst Outdated Show resolved Hide resolved
config/default_php8.rules Outdated Show resolved Hide resolved
doc/source/features.rst Outdated Show resolved Hide resolved
@jvoisin
Copy link
Owner

jvoisin commented May 27, 2024

Wow, that's a pretty neat PR, thanks!

@cgzones
Copy link
Contributor Author

cgzones commented May 29, 2024

In addition when the filter stream for the php wrapper is required, one could limit the depth of chained filters, e.g. set a value of 4 to permit php:://filter/a/b/c/d/resource=foo but deny php:://filter/a/b/c/d/e/resource=foo.

@jvoisin
Copy link
Owner

jvoisin commented May 29, 2024

I'm not sure limiting the depth will provide meaningful security improvements, nor that it'll be used to be honest :/

@jvoisin
Copy link
Owner

jvoisin commented Jun 6, 2024

This PR looks good to me, anything specific you're waiting on to mark it "Ready for review"?

@cgzones cgzones marked this pull request as ready for review June 7, 2024 18:19
@jvoisin
Copy link
Owner

jvoisin commented Jun 9, 2024

Merged, thanks <3

@jvoisin jvoisin closed this Jun 9, 2024
@cgzones cgzones deleted the stream_php branch August 10, 2024 10:05
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.

2 participants