Nextcloud HEIC Preview RCE via a Public Share Link (CVE-2026-49346)
A shared HEIC image can run code as www-data on Nextcloud instances with HEIC previews enabled and vulnerable libde265 (CVE-2026-49346, High 7.1).
TL;DR
- A crafted HEIC image shared through a public link runs a command on the Nextcloud server as
www-data. Pluto Security published the full chain on 2026-11-18. - Nextcloud 32 to 35 fpm-alpine images published before 2026-11-06, and AIO builds before 2026-10-22, shipped the vulnerable image libraries. HEIC previews must be enabled.
- The underlying libde265 flaw is CVE-2026-49346, CVSS v3.1 7.1 High. No exploitation in the wild is known, and it is not in CISA KEV as of 2026-11-21.
- Pull the current image and recreate the container, or update libde265 to 1.1.0 or later. Disabling HEIC previews removes the path. See "How do I fix it?".
Am I affected?
All of these conditions must hold for a Nextcloud instance to be exposed:
- Nextcloud generates HEIC previews. The
OC\Preview\HEICprovider is enabled inenabledPreviewProviders. - The host libraries are vulnerable. libde265 is earlier than 1.1.0, or libheif is earlier than 1.23.5.
- A HEIC file can reach preview generation. A public share link is enough, and so is any account that can upload a file and trigger a thumbnail.
- The instance runs an official image that installed the ImageMagick HEIC delegate before the fix, or the host has ImageMagick built with HEIC support.
Nextcloud does not enable HEIC previews by default in the 32 to 35 branches. The official fpm-alpine images installed imagemagick-heic, so an administrator who enabled the provider was exposed. The AIO Nextcloud container installed the same delegate until 2026-10-22.
The Nextcloud application has no bug in this chain. Its code asks ImageMagick for a thumbnail, ImageMagick routes the file by magic bytes, libheif reads the container and libde265 decodes the H.265 bitstream. The flaw sits four layers down, in a dependency of a dependency.
| Deployment | Affected versions | Fixed version |
|---|---|---|
Official nextcloud fpm-alpine images, Nextcloud 32 to 35 |
Images published before 2026-11-06 | Images published from 2026-11-06, including the current tags |
| Nextcloud AIO | Builds before commit ecc86b41 on 2026-10-22 |
Builds after 2026-10-22, on the Alpine 3.24 base |
| Other installs | libde265 earlier than 1.1.0, or libheif earlier than 1.23.5, with HEIC previews enabled | libde265 1.1.0 or later, or libheif 1.23.5 or later |
Either library fix blocks the chain. libde265 1.1.0 removes the integer overflow, and libheif 1.23.5 rejects the oversized coded frame before it reaches the decoder. The current Alpine 3.24 packages are libde265 1.1.3-r0 and libheif 1.23.7-r0.
Check the running container, not a freshly pulled image:
# Alpine-based Nextcloud container
docker exec <container> apk info -v | grep -E '^(imagemagick-heic|libde265|libheif)-'
# Debian-based container or host
docker exec <container> dpkg -l | grep -E 'libde265|libheif'
# ImageMagick HEIC delegate
docker exec <container> magick -list format | grep -i heic
On a bare-metal install, use dpkg -l, rpm -qa or apk info -v on the host. Check the provider configuration:
docker exec -u www-data <container> php occ config:list system | grep -i -A 20 enabledPreviewProviders
If the command prints nothing, the default provider list applies. In Nextcloud 32 to 35 that list does not include OC\Preview\HEIC.
How do I fix it?
Upgrade the image or the libraries, then recreate the container. Pulling a new image does not change a running container.
- Pull the current fpm-alpine tag and recreate the container:
docker pull nextcloud:35-fpm-alpine
docker stop <container>
docker rm <container>
docker run --name <container> ... nextcloud:35-fpm-alpine
- For Nextcloud AIO, update the Nextcloud container from the AIO interface so it uses a build after 2026-10-22.
- For a bare-metal or distribution install, upgrade libde265 to 1.1.0 or later and libheif to 1.23.5 or later. On Alpine 3.24,
apk upgradeinstalls libde265 1.1.3-r0 and libheif 1.23.7-r0. On Debian or Ubuntu, install the distribution update when it is available, or build the fixed libraries from source. - If the host cannot be updated, remove the ImageMagick HEIC delegate, or rebuild ImageMagick without HEIC support. That closes the path for this chain.
- Confirm the provider and the library versions after the restart.
If you cannot upgrade, disable HEIC previews. Set enabledPreviewProviders without OC\Preview\HEIC:
'enabledPreviewProviders' => [
'OC\Preview\PNG',
'OC\Preview\JPEG',
'OC\Preview\GIF',
'OC\Preview\WEBP',
],
The workaround closes the HEIC path only. HEIC files no longer get thumbnails, and users see a generic icon. It does not replace the library update, because another ImageMagick format could reach the same decoder in a different chain. If the key is unset, HEIC is already outside the default list in Nextcloud 32 to 35, so no change is needed on that axis.
The Docker fix removes the imagemagick-heic package from the image. The AIO fix removes the same package from its Nextcloud container. A bare-metal install keeps the host delegate, so the library update is the fix there.
What is the root cause?
libde265 computes the size of an image plane in 32-bit integers. A large HEIC frame wraps the allocation to about 1 KB, while the decoder later writes the real size into it.
libde265 is the open-source H.265 decoder under libheif. Nextcloud sends a HEIC file to ImageMagick, ImageMagick hands it to libheif, and libheif forwards the HEVC bitstream to libde265. The decoder reads the frame size from the Sequence Parameter Set in that bitstream.
The vulnerable allocation is in de265_image_get_buffer() in libde265/image.cc at v1.0.19:
int luma_stride = (spec->width + img->alignment-1) / img->alignment * img->alignment;
int chroma_stride = (rawChromaWidth + img->alignment-1) / img->alignment * img->alignment;
int luma_bpl = luma_stride * ((img->BitDepth_Y+7)/8);
int chroma_bpl = chroma_stride * ((img->BitDepth_C+7)/8);
int luma_height = spec->height;
int chroma_height = rawChromaHeight;
p[0] = static_cast<uint8_t*>(ALLOC_ALIGNED_16(luma_height * luma_bpl + MEMORY_PADDING));
spec->width and spec->height come from the SPS, and the bit depth can be 16. With those values, luma_height * luma_bpl exceeds the range of a signed 32-bit integer and wraps. The allocation becomes tiny. The later fill uses a size_t product and writes the real frame size:
const size_t plane_bytes =
(channel == 0 ? static_cast<size_t>(stride) * height
: static_cast<size_t>(chroma_stride) * chroma_height)
* bytes_per_pixel;
memset(pixels[channel], value, plane_bytes + MEMORY_PADDING);
The GHSA describes the result as a write of about 4 GB into an allocation of about 1 KB. libheif makes the second half possible.
Before 1.23.5 it checked the image size declared in the container's ispe property, not the coded frame size in the bitstream. A file can declare 64 by 64 pixels in ispe and a much larger frame in the SPS. libheif forwarded the file to libde265, and libde265 allocated for the in-band size.
How is it exploited?
An attacker uploads a crafted HEIC file, shares it through a public link, and triggers the thumbnail that starts the decode chain.
- The attacker builds a HEIC file with a small
ispesize, a large coded size in the SPS, 16-bit depth and HEVC PCM-coded data that places chosen bytes. - The attacker uploads the file to a Nextcloud account and creates a public share link.
- The attacker opens the link, or sends it to a user. The share page requests a thumbnail.
- Nextcloud calls ImageMagick, which routes the file to libheif by its magic bytes.
- libheif accepts the small container size, and libde265 reads the large coded size from the SPS.
- The plane allocation wraps. The fill and the PCM writes go past the buffer, and a heap spray places attacker-controlled data at the address the teardown will use.
- ImageMagick hits an error and runs its cleanup. The cleanup follows the crafted C++ smart pointer and calls
system()with the attacker's command. - The command runs as
www-data, the user that owns the Nextcloud data directory.
Pluto Security reports that the planted command can be up to 488 bytes. In its lab run the command created a file named PWNED.txt in the data directory. The firm says the chain is zero-click when the attacker can reach a remote instance and open the public link. It needs one click when a local deployment requires a user to open it.
No public exploit code has been released. The sequence comes from the published analysis and its lab demonstration.
How does the attack flow?
A public HEIC share reaches four parsers, the undersized plane wraps, and the decoder's own teardown runs the attacker's command as www-data.
public share link"] --> B["Nextcloud requests
a thumbnail"] B --> C["ImageMagick routes
by magic bytes"] C --> D["libheif checks the small
ispe size"] D --> E["libde265 reads a large
coded size from the SPS"] E --> F["Plane size wraps
to about 1 KB"] F --> G["PCM write overflows
the heap with chosen bytes"] G --> H["Teardown follows a fake
pointer to system()"] H --> I["Command runs as
www-data"]
What can an attacker do?
An attacker who reaches a vulnerable instance gets code execution as the account that owns every file in the Nextcloud data directory.
- Read and write every user's files, shares and versions in the data directory.
- Run
occaswww-data, which can create and delete users, reset passwords, enable or disable apps, change maintenance mode and rewrite system configuration. - Run a command of up to 488 bytes, enough for a reverse shell, an exfiltration one-liner or a loader for a larger payload.
- Use the Nextcloud account as a foothold for later access to connected storage or identity systems.
The impact stops at the Nextcloud container user in the demonstrated chain. Pluto Security says this is not a container escape, and the command does not run as root on the host. A deployment that mounts host paths into the container, or runs it with extra privileges, can extend the impact beyond the data directory.
The attacker needs a public share that reaches preview generation, HEIC previews enabled and the vulnerable libraries. No account is needed to open a public share.
Why does the fix work?
The libde265 fix changes the plane arithmetic to unsigned 32-bit values and performs the allocation multiplication in size_t, so the size can no longer wrap.
The fix commit 8a1b5cf2 changes the allocation in de265_image_get_buffer():
- int luma_stride = (spec->width + img->alignment-1) / img->alignment * img->alignment;
+ uint32_t luma_stride = (spec->width + img->alignment-1) / img->alignment * img->alignment;
- int luma_bpl = luma_stride * ((img->BitDepth_Y+7)/8);
+ uint32_t luma_bpl = luma_stride * ((img->BitDepth_Y+7)/8);
- p[0] = static_cast<uint8_t*>(ALLOC_ALIGNED_16(luma_height * luma_bpl + MEMORY_PADDING));
+ // Compute the plane sizes in size_t. Each operand fits in uint32_t, but the
+ // height * bytes-per-line product can exceed UINT32_MAX for large frames, so
+ // the multiplication must be done in 64 bits.
+ p[0] = static_cast<uint8_t*>(ALLOC_ALIGNED_16(static_cast<size_t>(luma_height) * luma_bpl + MEMORY_PADDING));
The allocation now reserves the real plane size, so the fill writes inside the buffer. The same commit converts the other plane allocation and the input-copy product. The libde265 1.1.0 release also adds de265_security_limits parameters to cap the maximum image size and memory use.
The fix is complete for CVE-2026-49346 in the code paths the commit touches. The libde265 advisory still lists "Patched versions: None" even though 1.1.0 records the CVE as fixed. Pluto Security flags that gap and the 7.1 score, which it says undersells the RCE. Readers should use 1.1.0 or later, not the empty advisory field.
libheif 1.23.5 adds an independent check. It scans the coded size in the HEVC SPS, and in the other codec headers, before any bytes reach a decoder plugin. Either the libde265 fix or the libheif check blocks this chain.
How do I check if I was compromised?
The published analysis lists no indicators of compromise, so there is no reliable signature for a successful attempt. These checks find the effects a successful chain would leave, not the HEIC file itself.
- List the admin accounts and compare them with your baseline:
docker exec -u www-data <container> php occ user:list
- List enabled apps and look for an app nobody installed:
docker exec -u www-data <container> php occ app:list
- Look for files created recently in the data directory, especially outside the normal user folders:
docker exec <container> find /var/www/html/data -type f -newermt '2026-11-01' -printf '%TY-%Tm-%Td %p\n' | head -50
- Check the web server log for a burst of preview requests from one address against a public share, followed by a new process or an outbound connection.
A hit is a lead, not proof. A public share can produce many legitimate preview requests, and a failed attempt may leave only those requests. If the checks show a new admin account, an unknown app or an unexpected file, treat the instance as compromised and rotate the secrets it stores.
Timeline
- 2026-05-26: libde265 1.1.0 is released with the integer-overflow fix, and GHSA-vv8h-932h-7r86 is published.
- 2026-06-19: CVE-2026-49346 is published.
- 2026-09-21: libheif 1.23.5 is released with the coded-size check.
- 2026-10-15: Pluto Security reports the full chain to Nextcloud with a proof of concept.
- 2026-10-20: Nextcloud merges PR #2604, which removes
imagemagick-heicfrom the fpm-alpine images. - 2026-10-22: Nextcloud AIO removes the same package from its Nextcloud container.
- 2026-10-23: Alpine 3.24 ships libde265 1.1.3-r0.
- 2026-11-06: Nextcloud publishes the updated fpm-alpine images.
- 2026-11-18: Pluto Security publishes the full technical write-up.
FAQ
Does this affect every Nextcloud instance?
No. HEIC previews must be enabled, the image libraries must be vulnerable, and a HEIC file must reach preview generation. Nextcloud 32 to 35 do not enable HEIC previews by default. The official images installed the HEIC delegate, so an administrator who enabled the provider was exposed.
Is the Nextcloud application itself vulnerable?
No. The memory-safety flaw is in libde265, and libheif's missing coded-size check lets the oversized frame reach it. Nextcloud's code correctly asks ImageMagick for a thumbnail and trusts the image stack underneath.
Is there a public exploit?
No public exploit code. Pluto Security published a full technical write-up and a lab demonstration on 2026-11-18, and it says it gave Nextcloud a full proof of concept privately on 2026-10-15.
What score does the CVE carry?
CVSS v3.1 7.1 High, with the vector CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:N/I:L/A:H. CISA's SSVC record marks Exploitation as poc. The score describes the decoder overflow. Pluto Security argues it undersells the unauthenticated RCE the chain achieves.
Does disabling HEIC previews break iPhone photo thumbnails?
Yes. HEIC files no longer get a preview, and users see a generic icon. That is the cost of the workaround. The library update keeps HEIC previews and closes the flaw.
Is the Docker image fix enough for a bare-metal install?
No. The Docker images removed the HEIC delegate. A bare-metal install uses the host's libde265 and libheif, so update those libraries or remove the host ImageMagick HEIC delegate.
Is AVIF affected by the same chain?
No. AVIF uses a different decoder, and this chain needs libde265 for H.265. libheif's 1.23.5 coded-size check covers every codec it routes, which is why it also blocks this HEIC path.
Replace the HEIC delegate before the next share link
Pull the current Nextcloud image or update libde265 to 1.1.0 or later, then confirm that the running container carries the fixed packages. If HEIC previews are not needed, turn the provider off as a second layer.
References
- Pluto Security, "What If a 'Crash' Bug Could Take Over Your Nextcloud Server?": https://pluto.security/blog/nextcloud-heic-rce-exploit-chain/ (checked November 21, 2026)
- CVE Program, CVE-2026-49346: https://www.cve.org/CVERecord?id=CVE-2026-49346 (checked November 21, 2026)
- GitHub Advisory Database, GHSA-vv8h-932h-7r86, "Heap buffer overflow in de265_image_get_buffer via SPS dimension integer overflow": https://github.com/advisories/GHSA-vv8h-932h-7r86 (checked November 21, 2026)
- libde265, fix commit 8a1b5cf212f78e1c77cb46eb5d56e492a9336eb8: https://github.com/strukturag/libde265/commit/8a1b5cf212f78e1c77cb46eb5d56e492a9336eb8 (checked November 21, 2026)
- libde265, release v1.1.0: https://github.com/strukturag/libde265/releases/tag/v1.1.0 (checked November 21, 2026)
- libheif, release v1.23.5: https://github.com/strukturag/libheif/releases/tag/v1.23.5 (checked November 21, 2026)
- Nextcloud, docker PR #2604, "Trim imagemagick modules from alpine image": https://github.com/nextcloud/docker/pull/2604 (checked November 21, 2026)
- Nextcloud, all-in-one commit ecc86b41fb, "Nextcloud: remove additional imagick (not-required) dependencies": https://github.com/nextcloud/all-in-one/commit/ecc86b41fb (checked November 21, 2026)
- Nextcloud,
PreviewManager.phpon the stable35 branch: https://github.com/nextcloud/server/blob/stable35/lib/private/PreviewManager.php (checked November 21, 2026) - Docker Hub,
library/nextcloud: https://hub.docker.com/r/library/nextcloud (checked November 21, 2026) - Alpine Linux, libde265 1.1.3-r0 on v3.24: https://pkgs.alpinelinux.org/packages?name=libde265&branch=v3.24&arch=x86_64 (checked November 21, 2026)
- Alpine Linux, libheif 1.23.7-r0 on v3.24: https://pkgs.alpinelinux.org/packages?name=libheif&branch=v3.24&arch=x86_64 (checked November 21, 2026)
- CISA, Known Exploited Vulnerabilities catalog, version 2026.11.20: https://www.cisa.gov/known-exploited-vulnerabilities-catalog (checked November 21, 2026)