[Bug]: Push::encodeNotif() can compute a negative subject budget → endless loop in Util::shortenMultibyteString(), PHP request hangs until max_execution_time
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
Start by reading lib/Push.php around Push::encodeNotif() and the Util::shortenMultibyteString() behavior described in the issue. Check existing tests for push payload encoding and multibyte string shortening, then reproduce with a proxy push payload whose link is 95–127 characters. Done means the request terminates and the subject or link is adjusted so the encoded payload fits.
索引モデルが issue の本文から書いたものです。
説明
⚠️ This issue respects the following points: ⚠️
- This is not a troubleshooting question, general support matter, or webserver/proxy problem, but likely a bug (if unsure, ask the Community Help Forum).
- This issue is not already reported on Github OR solved at the Community Help Forum (I've searched!).
- I'm using a maintained major version of Nextcloud Server and tested against the latest patch level. (Supported major versions and current patch levels).
- I agree to follow Nextcloud's Code of Conduct.
- I've tried my best to provide clear reproduction steps that someone unfamiliar with this bug could use to reproduce it.
Bug description
Versions
- Nextcloud server: 34.0.6
- notifications app:
- activity app:
- PHP:
- Office: Nextcloud Office (richdocuments) with Collabora Online
Summary
Since the update to 34.0.6, some WOPI PutFile requests (saving a document in Nextcloud Office) hang until max_execution_time (3600 s) is reached. Collabora aborts the save after ~30 s, the file stays locked for one hour (subsequent saves return 423 Locked) and the user gets "Document changed in storage (size mismatch after a failed upload)".
Root cause (analysis)
In lib/Push.php, encodeNotif():
$maxDataLength = $maxLength - strlen((string)json_encode($data)) - 2;
$data['subject'] = Util::shortenMultibyteString($notification->getParsedSubject(), $maxDataLength);
$data now includes link if strlen($link) < 128. For proxy push $maxLength is < 240. With a link of ~95–127 characters (plus json_encode escaping every / as \/) the encoded $data can exceed $maxLength - 2, so $maxDataLength becomes negative.
OCP\Util::shortenMultibyteString() loops while ((strlen(json_encode($temp)) - 2) > $dataLength). With a negative $dataLength the condition is always true (even for an empty string), so the loop never terminates.
Evidence
The notification is triggered by the activity "file changed" notification created during PutFile. In our logs, every hanging PutFile matches an activity_notification (app files) created at the same second with a link length of 95–101 characters, and a PHP fatal "Maximum execution time of 3600 seconds exceeded at lib/public/Util.php#605" exactly 3600 s later. Notifications with link length 82 (budget still positive) and 157 (link omitted because ≥ 128) did not hang.
Steps to reproduce
Steps to reproduce
- Have a user with a device registered for proxy push.
- Trigger a notification for that user whose link is ~95–127 characters long (e.g. activity "file changed" on a file in a deeper folder, saved via Nextcloud Office).
- The request creating the notification hangs until max_execution_time.
Expected behavior
Expected
The subject is shortened (or the link dropped) so the payload fits; the request never hangs.
Expected
The subject is shortened (or the link dropped) so the payload fits; the request never hangs.
Workaround we applied (local hotfix)
Directly after the budget calculation:
if ($maxDataLength < 20 && isset($data['link'])) {
unset($data['link']);
$maxDataLength = $maxLength - strlen((string)json_encode($data)) - 2;
}
$maxDataLength = max(0, $maxDataLength);
Additionally, Util::shortenMultibyteString() should probably guard against $dataLength < 0 itself.
Nextcloud Server version
34
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.5
Web server
Nginx
Database engine version
MySQL
Is this bug present after an update or on a fresh install?
Updated from a MINOR version (ex. 32.0.1 to 32.0.2)
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
- Default user-backend (database)
- LDAP/ Active Directory
- SSO - SAML
- Other
Configuration report
{
"system": {
"htaccess.RewriteBase": "\/",
"overwrite.cli.url": "https:\/\/nextcloud.XX.de",
"overwritehost": "nextcloud.XX.de",
"default_language": "de_DE",
"default_locale": "de_DE",
"default_phone_region": "DE",
"remember_login_cookie_lifetime": 1296000,
"session_lifetime": 7200,
"session_keepalive": true,
"auto_logout": false,
"allow_local_remote_servers": true,
"loglevel": 3,
"apps_paths": [
{
"path": "\/var\/www\/html\/apps",
"url": "\/apps",
"writable": false
},
{
"path": "\/var\/www\/html\/custom_apps",
"url": "\/custom_apps",
"writable": true
}
],
"memcache.local": "\\OC\\Memcache\\APCu",
"memcache.distributed": "\\OC\\Memcache\\Redis",
"memcache.locking": "\\OC\\Memcache\\Redis",
"filelocking.enabled": "true",
"redis": {
"host": "***REMOVED SENSITIVE VALUE***",
"port": 6379
},
"instanceid": "***REMOVED SENSITIVE VALUE***",
"passwordsalt": "***REMOVED SENSITIVE VALUE***",
"secret": "***REMOVED SENSITIVE VALUE***",
"onlyoffice": {
"jwt_secret": "***REMOVED SENSITIVE VALUE***",
"jwt_header": "Authorization",
"verify_peer_off": true
},
"trusted_domains": [
"nextcloud.XX.de",
"XXXXapp.XX.de",
"office.XX.de"
],
"datadirectory": "***REMOVED SENSITIVE VALUE***",
"tempdirectory": "\/var\/www\/tmp",
"dbtype": "mysql",
"version": "34.0.6.2",
"dbname": "***REMOVED SENSITIVE VALUE***",
"dbhost": "***REMOVED SENSITIVE VALUE***",
"dbport": "3306",
"dbtableprefix": "oc_",
"mysql.utf8mb4": true,
"dbuser": "***REMOVED SENSITIVE VALUE***",
"installed": true,
"ldapIgnoreNamingRules": false,
"skeletondirectory": "\/var\/www\/html\/core\/.skel\/",
"mail_smtpmode": "smtp",
"mail_sendmailmode": "smtp",
"mail_from_address": "***REMOVED SENSITIVE VALUE***",
"mail_domain": "***REMOVED SENSITIVE VALUE***",
"mail_smtphost": "***REMOVED SENSITIVE VALUE***",
"mail_smtpport": 22525,
"maintenance": false,
"maintenance_window_start": 1,
"theme": "",
"ebug": "true",
"share_folder": "geteilte-Dateien",
"filesystem_check_changes": 1,
"updater.server.url": "***REMOVED SENSITIVE VALUE***",
"app_install_overwrite": [],
"trusted_proxies": "***REMOVED SENSITIVE VALUE***",
"serverid": "0",
"dbpassword": "***REMOVED SENSITIVE VALUE***",
"mail_smtpsecure": "",
"mail_smtpauth": false
}
}
List of activated Apps
Enabled:
- activity: 7.0.0
- admin_audit: 1.24.0
- appointments: 2.9.0
- appstore: 1.0.0
- bruteforcesettings: 7.0.0
- calendar: 6.7.0
- circles: 34.0.0
- cloud_federation_api: 1.18.0
- comments: 1.24.0
- contacts: 8.10.0
- contactsinteraction: 1.15.0
- dashboard: 7.14.0
- dav: 1.40.0
- deck: 1.18.7
- federatedfilesharing: 1.24.0
- federation: 1.24.0
- files: 2.6.0
- files_downloadlimit: 5.2.0
- files_external: 1.26.0
- files_linkeditor: 1.1.27
- files_lock: 34.0.1
- files_pdfviewer: 7.0.1
- files_reminders: 1.7.0
- files_sharing: 1.26.1
- files_trashbin: 1.24.0
- files_versions: 1.27.0
- firstrunwizard: 7.0.0-dev.0
- forms: 5.4.3
- groupfolders: 22.0.6
- guests: 4.10.1
- logreader: 7.0.0
- lookup_server_connector: 1.22.0
- nextcloud_announcements: 6.0.0
- notes: 6.1.1
- notifications: 7.0.0-dev.1
- notify_push: 1.4.2
- oauth2: 1.22.0
- office: 1.0.0
- password_policy: 6.0.0-dev.0
- photos: 7.0.0
- polls: 9.3.0
- privacy: 6.0.0-dev.1
- XXXXdomainpolicy: 1.0.0
- profile: 1.3.0
- provisioning_api: 1.24.0
- recommendations: 7.0.0
- richdocuments: 11.1.3
- serverinfo: 6.0.0
- settings: 1.17.0
- sharebymail: 1.24.0
- spreed: 24.0.8
- support: 6.0.0
- survey_client: 6.0.0-dev.0
- suspicious_login: 12.0.0-dev.0
- systemtags: 1.24.0
- tasks: 0.18.1
- text: 8.0.1
- theming: 2.9.0
- twofactor_backupcodes: 1.23.0
- twofactor_totp: 16.0.0
- updatenotification: 1.24.0
- user_status: 1.14.0
- viewer: 7.0.0-dev.0
- weather_status: 1.14.0
- webhook_listeners: 1.6.0
- workflowengine: 2.16.0
Disabled:
- app_api: 34.0.0 (installed 34.0.0)
- encryption: 2.22.0 (installed 2.15.0)
- files_antivirus: 6.4.0 (installed 6.4.0)
- integration_excalidraw: 3.1.1 (installed 3.1.1)
- related_resources: 5.0.0-dev.0 (installed 1.0.3)
- twofactor_nextcloud_notification: 8.0.0
- user_ldap: 1.25.0 (installed 1.8.0)
- whiteboard: 1.5.9 (installed 1.5.9)
Nextcloud Signing status
No errors have been found.
Nextcloud Logs
Additional info
Versions
- Nextcloud server: 34.0.6
- notifications app: 7.0.0-dev.1 (as shipped with 34.0.6)
- activity app: 7.0.0
- PHP: 8.5.13
- Office: Nextcloud Office (richdocuments) with Collabora Online
- 主要言語
- PHP
- スター
- 37.6k
- フォーク
- 5.4k
- 平均マージ
- 1日 13時間
- マージ済み PR(30日)
- 623
環境構築
このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
nextcloud/server のほかの issue
-
0. Needs triage 35-feedback bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
34-feedback
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: GET /js/../<anything> returns 500 (NotPermittedException from JsController::getJs) instead of 404対応中かも @lazerg が 7 日前に担当しました。 オープン35-feedback
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
[Bug]: Dashboard widgets registered via OCA.Dashboard.register() sometimes never mount (spinner forever) – Vue 3 non-deep `callbacks` watcher race対応中かも @lazerg が 7 日前に担当しました。 オープン35-feedback
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
nextcloud/server の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
sonata-project/SonataAdminBundle#8426 ·
メンテナーはふだん 1 日以内に返信
-
good first issue help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 90/100
erkamyaman/rust-anything#942 ·
メンテナーはふだん 1 日以内に返信
-
CPU core labels missing for Low-Power E-cores on hybrid Intel CPUs (Arrow Lake-H) — get_intel_core_types() ignores /sys/devices/cpu_lowpower対応中かも @dgongut が今日担当しました。 オープン
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信