fix: validate public avatar path (#1416)
This commit is contained in:
parent
0bd7ecb9b0
commit
78bce0e29d
1 changed files with 6 additions and 0 deletions
|
|
@ -50,6 +50,7 @@ import { validate as isValidUUID } from 'uuid';
|
|||
import { EnvironmentService } from '../../integrations/environment/environment.service';
|
||||
import { TokenService } from '../auth/services/token.service';
|
||||
import { JwtAttachmentPayload, JwtType } from '../auth/dto/jwt-payload';
|
||||
import * as path from 'path';
|
||||
|
||||
@Controller()
|
||||
export class AttachmentController {
|
||||
|
|
@ -356,6 +357,11 @@ export class AttachmentController {
|
|||
throw new BadRequestException('Invalid image attachment type');
|
||||
}
|
||||
|
||||
const filenameWithoutExt = path.basename(fileName, path.extname(fileName));
|
||||
if (!isValidUUID(filenameWithoutExt)) {
|
||||
throw new BadRequestException('Invalid file id');
|
||||
}
|
||||
|
||||
const filePath = `${getAttachmentFolderPath(attachmentType, workspace.id)}/${fileName}`;
|
||||
|
||||
try {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue