Skip to content

Commit 3db1f12

Browse files
committed
fix: warn when secure signing is disabled
1 parent 1b4a187 commit 3db1f12

3 files changed

Lines changed: 29 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,22 @@
11
# Changelog
22

33

4+
## v6.7.3...main
5+
6+
[compare changes](https://github.com/nuxt-modules/og-image/compare/v6.7.3...main)
7+
8+
### 🩹 Fixes
9+
10+
- Parse queries from event paths ([#642](https://github.com/nuxt-modules/og-image/pull/642))
11+
12+
### 🏡 Chore
13+
14+
- Bump deps ([5bd2bdb3](https://github.com/nuxt-modules/og-image/commit/5bd2bdb3))
15+
16+
### ❤️ Contributors
17+
18+
- Harlan Wilton ([@harlan-zw](https://github.com/harlan-zw))
19+
420
## v6.7.2...main
521

622
[compare changes](https://github.com/nuxt-modules/og-image/compare/v6.7.2...main)

docs/content/3.guides/18.security.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ export default defineNuxtConfig({
7373
})
7474
```
7575

76+
::warning
77+
With signing disabled, an attacker can do more than trigger arbitrary renders: by supplying a `cacheKey` in the request they can **poison the runtime cache**, overwriting the cached image that your legitimate OG image URLs serve and spoofing the preview shown on social platforms. Only disable signing if the `/_og/` endpoint is otherwise protected (a WAF, origin restriction) or your images are fully prerendered.
78+
79+
URL signing will be **required in v7** whenever runtime image generation is enabled.
80+
::
81+
7682
### Setup (stable secret)
7783

7884
1. Generate a secret:

src/module.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,13 @@ export default defineNuxtModule<ModuleOptions>({
449449
if (!nuxt.options.dev || config.zeroRuntime || !hasServerRuntime)
450450
return
451451
if (signing.optOut) {
452-
logger.warn('OG image URL signing is disabled (`security.secret: false`). Anyone can craft arbitrary image generation requests.')
452+
logger.warn([
453+
'OG image URL signing is disabled (`security.secret: false`).',
454+
'Attackers can craft image requests and poison the cache so your real OG image URLs serve attacker-controlled content (content spoofing).',
455+
'Signing will be required in v7 whenever runtime image generation is enabled. Leave signing on, or set an explicit secret:',
456+
' NUXT_OG_IMAGE_SECRET=<secret>',
457+
' Generate one with: npx nuxt-og-image generate-secret',
458+
].join('\n'))
453459
}
454460
else if (signing.generated) {
455461
logger.warn([

0 commit comments

Comments
 (0)