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

XXE and Nextcloud #463

Closed
jvoisin opened this issue Sep 14, 2023 · 2 comments
Closed

XXE and Nextcloud #463

jvoisin opened this issue Sep 14, 2023 · 2 comments
Assignees

Comments

@jvoisin
Copy link
Owner

jvoisin commented Sep 14, 2023

Since some weeks Nextcloud itself calls libxml_set_external_entity_loader() to prevent any XML processing from loading external entities:

libxml_set_external_entity_loader(static function () {
	return null; 
});

Snuffleupagus logs this call if sp.xxe_protection.enable(); is enabled:

The problem is, that Nextcloud cannot parse its config.php if Snuffleupagus tries to nop the function:

Warning: [snuffleupagus][0.0.0.0][xxe][log] A call to libxml_set_external_entity_loader was tried and nopped in /nextcloud/lib/base.php on line 592
Config file has leading content, please remove everything before "<?php" in config.php
Fatal error: Uncaught Error: Typed static property OC::$server must not be accessed before initialization in /nextcloud/index.php:71 Stack trace: #0 {main} thrown in /nextcloud/index.php on line 71

More information about the issue here: hoellen/docker-nextcloud#42

@jvoisin jvoisin self-assigned this Sep 14, 2023
@jvoisin jvoisin added this to the 1.0.0 - Babar the Elephant milestone Sep 18, 2023
@jvoisin
Copy link
Owner Author

jvoisin commented Sep 20, 2023

I guess there is some logging-related shenenigans in how nextcloud handles configuration processing, as in it doesn't exploit Snuffleupagus to complain when it loads its configuration. I don't think there is much that can be done here from Snuffleupagus' side unfortunately.

Anyway, since Nextcloud is explicitly disabling XXE, there is no need to sp.xxe_protection.enable();; it can simply be replaced with something like this:

sp.disable_function.function("libxml_set_external_entity_loader").filename("/nextcloud/lib/base.php").allow(); 
sp.disable_function.function("libxml_set_external_entity_loader").drop(); 

@jvoisin jvoisin closed this as completed Sep 20, 2023
hoellen added a commit to hoellen/docker-nextcloud that referenced this issue Sep 21, 2023
@hoellen
Copy link

hoellen commented Sep 21, 2023

Thank you for your suggestion of dropping the call oflibxml_set_external_entity_loader.

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

No branches or pull requests

2 participants