Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
fix(plugins): accept single-label and underscore hosts in install URLs
Yudhi Armyndharisc917cc627e55
diff --git a/src/modules/plugins/dto/plugin.dto.spec.ts b/src/modules/plugins/dto/plugin.dto.spec.tsindex 53a38707a..349b64988 100644--- a/src/modules/plugins/dto/plugin.dto.spec.ts+++ b/src/modules/plugins/dto/plugin.dto.spec.ts@@ -30,6 +30,13 @@ describe('InstallFromUrlDto', () => {await expect(validate(dtoWith(`http://plugins.example/pkg.zip#sha256=${digest}`))).resolves.toHaveLength(0);});+ it('accepts single-label and underscore hosts, which the download guard allow-lists by name', async () => {+ const digest = 'a'.repeat(64);+ await expect(validate(dtoWith(`http://plugin-mirror:8080/x.zip#sha256=${digest}`))).resolves.toHaveLength(0);+ await expect(validate(dtoWith(`http://localhost:8080/p.zip#sha256=${digest}`))).resolves.toHaveLength(0);+ await expect(validate(dtoWith('https://h_x.example.com/p.zip'))).resolves.toHaveLength(0);+ });+it('rejects a non-http(s) scheme', async () => {const errors = await validate(dtoWith('ftp://plugins.example/pkg.zip'));diff --git a/src/modules/plugins/dto/plugin.dto.ts b/src/modules/plugins/dto/plugin.dto.tsindex 6dc353a18..90af6d90b 100644--- a/src/modules/plugins/dto/plugin.dto.ts+++ b/src/modules/plugins/dto/plugin.dto.ts@@ -95,7 +95,12 @@ export class InstallFromUrlDto {'transit. A pinned digest that does not match the downloaded archive fails the install.',})@IsString()- @IsUrl({ protocols: ['http', 'https'], require_protocol: true }, { message: 'url must be an absolute http(s) URL' })+ // require_tld:false + allow_underscores:true so single-label hosts (a compose service, `localhost`) reach+ // the SSRF guard, which admits them only when SSRF_ALLOWED_HOSTS names them.+ @IsUrl(+ { protocols: ['http', 'https'], require_protocol: true, require_tld: false, allow_underscores: true },+ { message: 'url must be an absolute http(s) URL' },+ )url!: string;}