Repository navigation
Description
How to use GitHub
- Please use the 👍 reaction to show that you are affected by the same issue.
- Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
- Subscribe to receive notifications on status change and new comments.
Steps to reproduce
- Log in to the Nextcloud Android or iOS app as
admin, which registers a proxy push device. - In the Nextcloud folder, run:
The object type and ID are 64 slashes each. JSON writes each
S=$(printf '/%.0s' $(seq 64)) sudo -u www-data php occ notification:generate admin test --object-type="$S" --object-id="$S"
/as\/, so they exceed the 200-byte proxy payload before the subject is added.
Expected behaviour
occ notification:generate returns.
Actual behaviour
occ notification:generate never returns and uses 100% of one CPU core.
On my server, cron.php looped the same way when the announcements crawler pushed the announcement with the link https://cert.europa.eu/publications/security-advisories/2026-018 to admin.
Cause
encodeNotif() gives the subject the bytes that the other fields leave of the 200-byte proxy payload:
Lines 908 to 932 in cd6d232
| protected function encodeNotif(int $id, INotification $notification, int $maxLength): array { | |
| $data = [ | |
| 'nid' => $id, | |
| 'app' => $notification->getApp(), | |
| 'subject' => '', | |
| 'type' => $notification->getObjectType(), | |
| 'id' => $notification->getObjectId(), | |
| ]; | |
| // The link lets the service worker navigate on notificationclick; the | |
| // subject budget below shrinks accordingly, very long links are dropped | |
| $link = $notification->getLink(); | |
| if ($link !== '' && strlen($link) < 128) { | |
| $data['link'] = $link; | |
| } | |
| // Max length of encryption is ~240, so we need to make sure the subject is shorter. | |
| // Also, subtract two for encapsulating quotes will be added. | |
| $maxDataLength = $maxLength - strlen((string)json_encode($data)) - 2; | |
| $data['subject'] = Util::shortenMultibyteString($notification->getParsedSubject(), $maxDataLength); | |
| if ($notification->getParsedSubject() !== $data['subject']) { | |
| $data['subject'] .= '…'; | |
| } | |
| return $data; | |
| } |
If the other fields take more than 198 bytes, that length is negative, and OCP\Util::shortenMultibyteString() loops forever. Its condition strlen(json_encode($temp)) - 2 > $dataLength stays true even for ''.
In my case, the link caused it. Since #3478, first shipped in 35.0.3, the other fields include the link. With it, the announcement's other fields took 207 bytes, so the length was 200 - 207 - 2 = -9. Without it, the length is 70.
Fix idea
- In
encodeNotif(), drop the link when it makes the length negative. - Pass at least 0 to
shortenMultibyteString(), so that long object types or IDs cannot loop either.
Server configuration
Nextcloud version: 35.0.3 (notifications 8.0.1)
Activity
nickvergessen commentedon Nov 15, 2026
That sounds weird, as that uses much shorter objectId (value this time was 5), ah nvm we add the link in the push content.
Rest however sounds plausible and we should try to address it
nickvergessen commentedon Nov 15, 2026
This is not considered a valid behaviour for the app sending the notification and it will result in errors if that makes the object data too long.
But it should not create an infinite loop
mafel786 commentedon Nov 15, 2026
Additional data point from our instance: 34.0.6 (bundled notifications
7.0.0-dev.1, whoseencodeNotif()already adds the link). Here the trigger was the coreCheckCodeIntegrityJobrun bycron.php.The integrity result had changed (a single modified
core/js/mimetypelist.jsafter we added a custom mimetype mapping), so the job notified the admins. Its object ID is the 64-char sha256 fingerprint and the link is 59 chars, so the subject budget inencodeNotif(…, 200)becomes -13.cron.phpthen hung for 14 h at 100 % CPU on one core (no syscalls, no I/O).Stack captured via pcntl alarm:
A stable34 backport of #3603 and nextcloud/server#66629 would fix this for us.