diff --git a/.github/SECURITY.md b/.github/SECURITY.md index 4f9b6c02..aa657a94 100644 --- a/.github/SECURITY.md +++ b/.github/SECURITY.md @@ -54,3 +54,9 @@ Out-of-scope (unless chainable to significant impact): - Missing best-practice headers only - Self-XSS without escalation path - Rate-limit bypass with no practical abuse impact + +## Acknowledgements + +Thank you to everyone who has reported security issues responsibly. + +- **birb ([@parabirb](https://github.com/parabirb))**, whose audit of [Flare](https://github.com/FlintSH/Flare), the project Emberly was originally forked from, found issues that also affected Emberly: stored XSS through uploaded SVG and HTML files, unlimited file password guessing, and unthrottled OCR. Fixed in Emberly 3.2.1. diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 5e67f42c..5b2a2fc0 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -13,6 +13,10 @@ jobs: dashboard: if: github.event_name == 'workflow_dispatch' || startsWith(github.event.release.tag_name, 'v') runs-on: ubuntu-latest + env: + # Docker Hub is optional: set DOCKERHUB_USERNAME and DOCKERHUB_TOKEN secrets to publish there too + DOCKERHUB_ENABLED: ${{ secrets.DOCKERHUB_USERNAME != '' && secrets.DOCKERHUB_TOKEN != '' }} + DOCKERHUB_IMAGE: docker.io/${{ vars.DOCKERHUB_NAMESPACE || secrets.DOCKERHUB_USERNAME }}/emberly steps: - uses: actions/checkout@v6 @@ -25,10 +29,18 @@ jobs: username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} + - if: env.DOCKERHUB_ENABLED == 'true' + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + - id: meta uses: docker/metadata-action@v5 with: - images: ghcr.io/${{ github.repository_owner }}/emberly + images: | + ghcr.io/${{ github.repository_owner }}/emberly + ${{ env.DOCKERHUB_ENABLED == 'true' && env.DOCKERHUB_IMAGE || '' }} tags: | type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} diff --git a/.gitignore b/.gitignore index ed4eaaa1..11617f57 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,7 @@ Thumbs.db .idea *.traineddata .tmp/uploads + +# Generated by scripts/site-licenses.mjs +THIRD_PARTY_LICENSES.txt +apps/dashboard/public/licenses/ diff --git a/Dockerfile b/Dockerfile index 07134a0f..eccc4d89 100644 --- a/Dockerfile +++ b/Dockerfile @@ -25,6 +25,8 @@ FROM deps AS build COPY turbo.json ./ COPY packages packages COPY apps/dashboard apps/dashboard +COPY LICENSE THIRD_PARTY_NOTICES.md ./ +COPY scripts scripts ENV BUILD_STANDALONE=1 RUN bun run --cwd packages/db db:generate \ && bun run --cwd apps/dashboard build @@ -59,6 +61,8 @@ COPY --from=build --chown=emberly:emberly /repo/apps/dashboard/.next/standalone COPY --from=build --chown=emberly:emberly /repo/apps/dashboard/.next/static ./apps/dashboard/.next/static COPY --from=build --chown=emberly:emberly /repo/apps/dashboard/public ./apps/dashboard/public COPY --chmod=755 apps/dashboard/docker-entrypoint.sh /usr/local/bin/emberly-entrypoint +COPY LICENSE THIRD_PARTY_NOTICES.md ./ +COPY --from=build /repo/apps/dashboard/public/licenses/packages.txt ./THIRD_PARTY_LICENSES.txt USER emberly VOLUME ["/data"] diff --git a/README.md b/README.md index a8b9fb66..0983e50e 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,10 @@ See [CONTRIBUTING.md](.github/CONTRIBUTING.md). Please report security issues pr - [Discord](https://discord.gg/36spBmzZVB) - [support@embrly.ca](mailto:support@embrly.ca) +## Acknowledgements + +Emberly started as a fork of [Flare](https://github.com/FlintSH/Flare) by Zachary Lowery ([@FlintSH](https://github.com/FlintSH)). Thank you to Zach and Flare's contributors for the foundation Emberly is built on. Portions derived from Flare remain under its MIT license, reproduced in [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). + ## License Emberly is licensed under the [Elastic License 2.0](LICENSE). You can use, modify and self-host it, including for your business. You may not offer it to others as a hosted service, or get around its license keys. Releases before the switch remain available under the GNU AGPL v3. diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md new file mode 100644 index 00000000..f6b09a48 --- /dev/null +++ b/THIRD_PARTY_NOTICES.md @@ -0,0 +1,57 @@ +# Third-party notices + +Emberly includes work from the projects below. Their licenses apply to the portions of Emberly derived from them. + +The Docker image also includes `THIRD_PARTY_LICENSES.txt`, generated at build time, with the license of every open-source package Emberly ships with. + +## Flare + +Emberly started as a fork of [Flare](https://github.com/FlintSH/Flare) by Zachary Lowery ([@FlintSH](https://github.com/FlintSH)). Portions derived from Flare remain under its MIT license: + +```text +MIT License + +Copyright (c) Zachary Lowery + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +``` + +## shadcn/ui + +The components in `apps/dashboard/components/ui` are adapted from [shadcn/ui](https://github.com/shadcn-ui/ui): + +```text +MIT License + +Copyright (c) 2023 shadcn + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` + +## Inter + +Emberly bundles the [Inter](https://github.com/rsms/inter) typeface by Rasmus Andersson and the Inter Project Authors, licensed under the SIL Open Font License 1.1. The full license is included with the font files in `apps/dashboard/public/fonts/inter/OFL.txt`. + +## Font Awesome + +The Windows, Apple and Linux logos on the Downloads page are [Font Awesome Free](https://fontawesome.com) icons by Fonticons, Inc., used unmodified under the [Creative Commons Attribution 4.0 International License](https://creativecommons.org/licenses/by/4.0/). Full license: https://fontawesome.com/license/free. diff --git a/apps/dashboard/CHANGELOG.md b/apps/dashboard/CHANGELOG.md index 28e3252c..dc226dd6 100644 --- a/apps/dashboard/CHANGELOG.md +++ b/apps/dashboard/CHANGELOG.md @@ -10,6 +10,31 @@ The format is based on "Keep a Changelog" and follows [Semantic Versioning](http - **A Downloads page.** `/downloads` offers Flicker, Emberly's desktop app, with a button for the visitor's system (Windows, macOS or Linux) and every installer listed by platform, with sizes. The version, date and files come from the latest Flicker release on GitHub, cached for 10 minutes, and the last good copy is shown if GitHub is unavailable. The page also covers ShareX, Flameshot, Spectacle, scripts and the API, with setup guides. It's linked from the navbar, the footer and **Profile → Uploads**, and works on self-hosted instances too. +### Fixed + +- **Admin → Reports and Admin → Applications crashed when there was nothing to show**, with "Something went wrong" instead of the empty list. +- **Eight emails used a generic fallback layout**: role changed, account suspended and restored, API key created and revoked, backup codes generated and used, session revoked, and suspicious activity. Each now has its own wording and details, and links to the right settings page. +- **Files missing from storage returned an error instead of "not found".** Raw links and `/api/files` now return `404` when the stored object is gone. Other storage failures are logged with the file, its storage path and the storage provider's status and request ID, instead of `[object Object]`. With S3, a `403` usually means the object is missing and the access key can't list the bucket, or the key can't read it. + +### Changed + +- **File passwords must be at least 8 characters.** This applies to new passwords only; existing ones keep working until they're changed. +- **Credit to Flare.** Emberly began as a fork of [Flare](https://github.com/FlintSH/Flare) by Zachary Lowery. The README now says so, `LICENSE` points to Flare's MIT license in `THIRD_PARTY_NOTICES.md`, and the Docker image now includes both. +- **Open-source credits.** `THIRD_PARTY_NOTICES.md` now also credits shadcn/ui (whose components `components/ui` is built on), the Inter typeface, and the Font Awesome icons on the Downloads page, and Inter's license now ships with the font files. A new **Licenses** page (`/licenses`), linked from the footer, shows Emberly's own license, these notices, and the license of all 799 open-source packages Emberly ships with, with a search box. The list is generated on every build, and the Docker image also includes it as `THIRD_PARTY_LICENSES.txt`; run `bun run licenses` to generate it yourself. The About page has a new **Built on open source** section that credits Flare and links to it. +- **The Docker image can also be published to Docker Hub.** Set the `DOCKERHUB_USERNAME` and `DOCKERHUB_TOKEN` repository secrets (and optionally a `DOCKERHUB_NAMESPACE` variable) and each release is pushed there as well as to GitHub Packages. + +### Security + +These issues were found by birb ([@parabirb](https://github.com/parabirb)) in an audit of Flare, the project Emberly was originally forked from, and also affected Emberly. Thank you. + +- **Uploaded SVG and HTML files could run scripts on the Emberly site.** Raw file links and thumbnails served them with the uploader's file type and no Content-Security-Policy, so opening one ran its JavaScript with the viewer's session. Every response that serves an uploaded file now sends `Content-Security-Policy: sandbox` and `X-Content-Type-Options: nosniff`, and thumbnails are only served for raster images. Related: [GHSA-4fr7-p4rm-r2f6](https://github.com/FlintSH/Flare/security/advisories/GHSA-4fr7-p4rm-r2f6). +- **File passwords could be guessed without limit.** After 10 wrong passwords for a file from one address in 15 minutes, that address gets `429` for the file, and after 100 wrong passwords in total the file stops accepting guesses for the rest of the window. A correct password is remembered for 10 minutes, so streaming a protected video no longer checks it on every request. Related: [GHSA-qxr9-m5ff-27rv](https://github.com/FlintSH/Flare/security/advisories/GHSA-qxr9-m5ff-27rv). +- **Anyone could start text extraction (OCR) repeatedly** on a public image, exhausting CPU and memory. On-demand OCR now runs one image at a time with at most 10 waiting (more get `503`), each account or address can start 20 per 10 minutes (then `429`), an image that failed isn't retried for 5 minutes, and failed images are only retried by their owner. Errors no longer include storage details. Related: [GHSA-7p5v-2m9m-3p9m](https://github.com/FlintSH/Flare/security/advisories/GHSA-7p5v-2m9m-3p9m). +- **Theme colors weren't validated** before being written into the page's styles. Colors and theme names must now be plain values, and anything else saved earlier is dropped when the page is rendered. This wasn't exploitable against other people in Emberly, since only superadmins set the site's colors and your own colors only apply to you. Related: [GHSA-jf87-vxjh-6gv2](https://github.com/FlintSH/Flare/security/advisories/GHSA-jf87-vxjh-6gv2). +- **Downloads of private and password-protected files** now send `Cache-Control: private, no-store`, so a CDN can't keep a copy. Raw links already did. Related: [GHSA-5gjg-xfq3-pp83](https://github.com/FlintSH/Flare/security/advisories/GHSA-5gjg-xfq3-pp83). + +After upgrading, purge `/*/*/raw`, `/api/files/*` and `/api/files/*/thumbnail` from any CDN or caching proxy, since public files were cached with the old headers. + --- ## [3.2.0] - 2026-10-24 diff --git a/apps/dashboard/app/(main)/[userUrlId]/[filename]/page.tsx b/apps/dashboard/app/(main)/[userUrlId]/[filename]/page.tsx index c061d859..345148d6 100644 --- a/apps/dashboard/app/(main)/[userUrlId]/[filename]/page.tsx +++ b/apps/dashboard/app/(main)/[userUrlId]/[filename]/page.tsx @@ -4,7 +4,6 @@ import { headers } from 'next/headers' import Link from 'next/link' import { notFound } from 'next/navigation' -import { compare } from 'bcryptjs' import { ShieldAlert } from 'lucide-react' import { getServerSession } from 'next-auth' @@ -26,6 +25,7 @@ import { } from '@/lib/embeds/metadata' import { queuePreview } from '@/lib/embeds/preview' import { findFileByUrlPath } from '@/lib/files/lookup' +import { checkFilePassword, clientAddress } from '@/lib/files/password-guard' import { formatFileSize } from '@/lib/utils' export const dynamic = 'force-dynamic' @@ -288,11 +288,12 @@ export default async function FilePage({ ) } - const isPasswordValid = await compare( + const passwordCheck = await checkFilePassword( + serializedFile.password, providedPassword, - serializedFile.password + clientAddress(await headers()) ) - if (!isPasswordValid) { + if (!passwordCheck.ok) { return (
- The password you entered is incorrect + {passwordCheck.limited + ? `Too many wrong passwords. Try again in ${Math.ceil(passwordCheck.retryAfter / 60)} minutes.` + : 'The password you entered is incorrect'}