Skip to content
Merged

Dev #132

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
14 changes: 13 additions & 1 deletion .github/workflows/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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}}
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,7 @@ Thumbs.db
.idea
*.traineddata
.tmp/uploads

# Generated by scripts/site-licenses.mjs
THIRD_PARTY_LICENSES.txt
apps/dashboard/public/licenses/
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"]
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
57 changes: 57 additions & 0 deletions THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
@@ -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.
25 changes: 25 additions & 0 deletions apps/dashboard/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 11 additions & 6 deletions apps/dashboard/app/(main)/[userUrlId]/[filename]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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'
Expand Down Expand Up @@ -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 (
<div className="flex-1 relative min-h-screen overflow-hidden">
<DynamicBackground />
Expand All @@ -307,10 +308,14 @@ export default async function FilePage({
<Card className="w-full max-w-md glass">
<div className="p-6">
<h1 className="text-xl font-medium text-center mb-4">
Incorrect Password
{passwordCheck.limited
? 'Too many attempts'
: 'Incorrect Password'}
</h1>
<p className="text-sm text-muted-foreground text-center mb-6">
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'}
</p>
<form className="space-y-4" action={urlPath}>
<div className="space-y-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const dynamic = 'force-dynamic'
*/
export async function GET(
request: NextRequest,
{ params }: { params: Promise<{ userUrlId: string; filename: string }> },
{ params }: { params: Promise<{ userUrlId: string; filename: string }> }
) {
const { userUrlId, filename } = await params
const urlPath = `/${userUrlId}/${filename}`
Expand All @@ -29,16 +29,30 @@ export async function GET(

// Fetch file record (handles space→dash fallback automatically)
const file = await findFileByUrlPath(userUrlId, filename, {
select: { name: true, mimeType: true, visibility: true, password: true, userId: true },
select: {
name: true,
mimeType: true,
visibility: true,
password: true,
userId: true,
},
})

if (!file || !file.mimeType.startsWith('video/')) {
return new NextResponse('Not Found', { status: 404 })
}

const session = await getServerSession(authOptions)
const deny = await checkFileAccess(file, { userId: (session?.user as { id?: string })?.id, providedPassword: password })
if (deny) return new NextResponse(deny.status === 404 ? 'Forbidden' : 'Unauthorized', { status: deny.status })
const deny = await checkFileAccess(file, {
userId: (session?.user as { id?: string })?.id,
providedPassword: password,
request,
})
if (deny)
return new NextResponse(
deny.status === 404 ? 'Forbidden' : 'Unauthorized',
{ status: deny.status }
)

const rawUrl = buildRawUrl(urlPath, password)

Expand Down
33 changes: 33 additions & 0 deletions apps/dashboard/app/(marketing)/about/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,39 @@ export default async function AboutPage() {
</GlassCard>
)}

<GlassCard>
<div className="flex flex-col gap-6 p-8 md:flex-row md:items-center md:justify-between">
<div className="max-w-2xl space-y-2">
<h2 className="text-2xl font-bold">Built on open source</h2>
<p className="leading-relaxed text-muted-foreground">
Emberly started as a fork of{' '}
<a
href="https://github.com/FlintSH/Flare"
target="_blank"
rel="noopener noreferrer"
className="text-primary hover:underline"
>
Flare
</a>{' '}
by Zachary Lowery, and is built with Next.js, React, Prisma,
Radix, shadcn/ui, CodeMirror and Tesseract.js, along with
hundreds of other open-source projects. Thank you to everyone
who makes them.
</p>
</div>
<Button
variant="outline"
className="shrink-0 bg-background/50"
asChild
>
<Link href="/licenses">
<BookOpen className="mr-2 h-4 w-4" />
Licenses and credits
</Link>
</Button>
</div>
</GlassCard>

{/* CTA Section */}
<GlassCard>
<div className="p-8 text-center">
Expand Down
22 changes: 22 additions & 0 deletions apps/dashboard/app/(marketing)/licenses/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { LicensesView } from '@/components/licenses/licenses-view'
import PageShell from '@/components/layout/PageShell'

import { buildPageMetadata } from '@/lib/embeds/metadata'

export const metadata = buildPageMetadata({
title: 'Licenses',
description:
'Emberly’s license, and the open-source software it’s built with.',
})

export default function LicensesPage() {
return (
<PageShell
eyebrow="Resources"
title="Licenses"
subtitle="Emberly’s license, and the open-source software it’s built with."
>
<LicensesView />
</PageShell>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export async function GET(
const deny = await checkFileAccess(file, {
userId: session?.user?.id,
providedPassword,
request: req,
})
if (deny) return deny

Expand Down
20 changes: 17 additions & 3 deletions apps/dashboard/app/(raw)/[userUrlId]/[filename]/raw/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import {
emptyResponse,
serveStoredFile,
} from '@/lib/files/serve'
import { loggers } from '@/lib/logger'
import { describeStorageError, isStorageNotFound } from '@/lib/storage/errors'

const logger = loggers.files

type Params = { params: Promise<{ userUrlId: string; filename: string }> }

Expand All @@ -15,6 +19,7 @@ export async function OPTIONS() {
}

async function handle(req: Request, { params }: Params, head: boolean) {
let logContext: Record<string, unknown> = {}
try {
const { userUrlId, filename } = await params
const file = await findFileByUrlPath(userUrlId, filename)
Expand All @@ -23,13 +28,22 @@ async function handle(req: Request, { params }: Params, head: boolean) {
const deny = await denyFileAccess(req, file)
if (deny) return deny

logContext = {
urlPath: `/${userUrlId}/${filename}`,
storagePath: file.path,
storageBucketId: file.storageBucketId,
}
return await serveStoredFile(req, file, { head })
} catch (error) {
if (error instanceof Error && error.message.includes('NoSuchKey')) {
if (isStorageNotFound(error)) {
logger.warn('Stored file is missing', logContext)
return emptyResponse(404)
}
console.error('File serve error:', error)
return emptyResponse(500)
logger.error('File serve error', error, {
...logContext,
storage: describeStorageError(error),
})
return emptyResponse(502)
}
}

Expand Down
Loading
Loading