nextcloud / terms_of_service

📜 Requires users to accept the terms of service before accessing data.
https://apps.nextcloud.com/apps/terms_of_service
GNU Affero General Public License v3.0
31 stars 20 forks source link

ArithmeticError: Bit shift by negative number at <<closure>> #797

Closed sirdrakeistda closed 1 year ago

sirdrakeistda commented 1 year ago

Nextcloud file is ot usable due to this error. Deactivating terms of services fixes the error, so its caused by this app. Setup: Nextcloud 25.0.3 Terms of Services: 2.0.1

Error log:

[webdav] Fehler: ArithmeticError: Bit shift by negative number at <<closure>>

 0. /var/www/nextcloud/apps/terms_of_service/lib/Checker.php line 157
    OCA\TermsOfService\Checker->matchCidr()
 1. /var/www/nextcloud/apps/terms_of_service/lib/Checker.php line 140
    OCA\TermsOfService\Checker->isWOPIRemoteAddress()
 2. /var/www/nextcloud/apps/terms_of_service/lib/Checker.php line 98
    OCA\TermsOfService\Checker->isValidWOPIRequest()
 3. /var/www/nextcloud/apps/terms_of_service/lib/Filesystem/Helper.php line 116
    OCA\TermsOfService\Checker->currentUserHasSigned()
 4. /var/www/nextcloud/apps/terms_of_service/lib/Filesystem/CacheWrapper.php line 43
    OCA\TermsOfService\Filesystem\Helper->verifyAccess()
 5. /var/www/nextcloud/lib/private/Files/Cache/Wrapper/CacheWrapper.php line 78
    OCA\TermsOfService\Filesystem\CacheWrapper->formatCacheEntry()
 6. /var/www/nextcloud/lib/private/Files/View.php line 1343
    OC\Files\Cache\Wrapper\CacheWrapper->get()
 7. /var/www/nextcloud/lib/private/Files/View.php line 1394
    OC\Files\View->getCacheEntry()
 8. /var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php line 218
    OC\Files\View->getFileInfo()
 9. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php line 78
    OCA\DAV\Connector\Sabre\Directory->getChild()
10. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php line 73
    Sabre\DAV\Tree->getNodeForPath()
11. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 971
    Sabre\DAV\Tree->getNodeForPath()
12. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 1662
    Sabre\DAV\Server->getPropertiesIteratorForPath()
13. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 1647
    Sabre\DAV\Server->writeMultiStatus()
14. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 346
    Sabre\DAV\Server->generateMultiStatus()
15. /var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
    Sabre\DAV\CorePlugin->httpPropFind()
16. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 472
    Sabre\DAV\Server->emit()
17. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 253
    Sabre\DAV\Server->invokeMethod()
18. /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php line 321
    Sabre\DAV\Server->start()
19. /var/www/nextcloud/apps/dav/lib/Server.php line 360
    Sabre\DAV\Server->exec()
20. /var/www/nextcloud/apps/dav/appinfo/v2/remote.php line 35
    OCA\DAV\Server->exec()
21. /var/www/nextcloud/remote.php line 171
    require_once("/var/www/nextcl ... p")

PROPFIND /remote.php/dav/files/user/Software+Betriebsysteme/VirtualBox%20VM
from 167.74.9.157 by user at 2023-02-04T10:13:03+00:00
nickvergessen commented 1 year ago

Can you share the full log line from nextcloud.log file?

sirdrakeistda commented 1 year ago
{"reqId":"Y94vVY3cKuFfoOaEjgna9QAAAJI","level":3,"time":"2023-02-04T10:11:33+00:00","remoteAddr":"167.74.9.157","user":"user","app":"webdav","method":"PROPFIND","url":"/remote.php/dav/files/user/Software+Betriebsysteme/VirtualBox%20VM","message":"Bit shift by negative number","userAgent":"Mozilla/5.0 (Linux) mirall/3.6.6-20230120.115834.ff2293824-1.0~jammy1 (Nextcloud, ubuntu-5.15.0-58-generic ClientArchitecture: x86_64 OsArchitecture: x86_64)","version":"25.0.3.2","exception":{"Exception":"ArithmeticError","Message":"Bit shift by negative number","Code":0,"Trace":[{"file":"/var/www/nextcloud/apps/terms_of_service/lib/Checker.php","line":157,"function":"matchCidr","class":"OCA\\TermsOfService\\Checker","type":"->"},{"file":"/var/www/nextcloud/apps/terms_of_service/lib/Checker.php","line":140,"function":"isWOPIRemoteAddress","class":"OCA\\TermsOfService\\Checker","type":"->"},{"file":"/var/www/nextcloud/apps/terms_of_service/lib/Checker.php","line":98,"function":"isValidWOPIRequest","class":"OCA\\TermsOfService\\Checker","type":"->"},{"file":"/var/www/nextcloud/apps/terms_of_service/lib/Filesystem/Helper.php","line":116,"function":"currentUserHasSigned","class":"OCA\\TermsOfService\\Checker","type":"->"},{"file":"/var/www/nextcloud/apps/terms_of_service/lib/Filesystem/CacheWrapper.php","line":43,"function":"verifyAccess","class":"OCA\\TermsOfService\\Filesystem\\Helper","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/Cache/Wrapper/CacheWrapper.php","line":78,"function":"formatCacheEntry","class":"OCA\\TermsOfService\\Filesystem\\CacheWrapper","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":1343,"function":"get","class":"OC\\Files\\Cache\\Wrapper\\CacheWrapper","type":"->"},{"file":"/var/www/nextcloud/lib/private/Files/View.php","line":1394,"function":"getCacheEntry","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Connector/Sabre/Directory.php","line":218,"function":"getFileInfo","class":"OC\\Files\\View","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php","line":78,"function":"getChild","class":"OCA\\DAV\\Connector\\Sabre\\Directory","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Tree.php","line":73,"function":"getNodeForPath","class":"Sabre\\DAV\\Tree","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":971,"function":"getNodeForPath","class":"Sabre\\DAV\\Tree","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":1662,"function":"getPropertiesIteratorForPath","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":1647,"function":"writeMultiStatus","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php","line":346,"function":"generateMultiStatus","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php","line":89,"function":"httpPropFind","class":"Sabre\\DAV\\CorePlugin","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":472,"function":"emit","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":253,"function":"invokeMethod","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php","line":321,"function":"start","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/lib/Server.php","line":360,"function":"exec","class":"Sabre\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/apps/dav/appinfo/v2/remote.php","line":35,"function":"exec","class":"OCA\\DAV\\Server","type":"->"},{"file":"/var/www/nextcloud/remote.php","line":171,"args":["/var/www/nextcloud/apps/dav/appinfo/v2/remote.php"],"function":"require_once"}],"File":"/var/www/nextcloud/apps/terms_of_service/lib/Checker.php","Line":178,"message":"Bit shift by negative number","exception":[],"CustomMessage":"Bit shift by negative number"},"id":"63de55ce0a3db"}
nickvergessen commented 1 year ago

Can you also share the wopi allow list? Either from occ:

sudo -u www-data php occ config:app:get richdocuments wopi_allowlist

or by generating a config report in the support app

sirdrakeistda commented 1 year ago

Allow list wopi requests: local ip adress, 127.0.0.1, nextcloud.server.url, 127.0.0.1/9980

nickvergessen commented 1 year ago

I guess the /9980 is the problem. the allowlist is not supposed to contain subpaths (neither port if that was the intention)

sirdrakeistda commented 1 year ago

Thanks, that fixed the issue for me.

nickvergessen commented 1 year ago

Will keep it open to save guard the code against bad entries

nickvergessen commented 1 year ago

Fixed with https://github.com/nextcloud/terms_of_service/pull/799