fix: resolve a vulnerability with admin token (#1345)

By default, the jellyfinAuthToken of every user was always retrieved from the database, and
sometimes sent back to the client. Any logged-in user could retrieve this token via a request
containing admin user information, and use it to gain full access to Jellyfin. This PR removes the
auth token and the device ID from the fields selected by default by TypeORM.
This commit is contained in:
Gauthier
2025-02-10 00:17:11 +01:00
committed by GitHub
parent 2dbd1096d2
commit 620135aeac
2 changed files with 4 additions and 3 deletions

View File

@@ -83,13 +83,13 @@ export class User {
@Column({ nullable: true }) @Column({ nullable: true })
public jellyfinUserId?: string; public jellyfinUserId?: string;
@Column({ nullable: true }) @Column({ nullable: true, select: false })
public jellyfinDeviceId?: string; public jellyfinDeviceId?: string;
@Column({ nullable: true }) @Column({ nullable: true, select: false })
public jellyfinAuthToken?: string; public jellyfinAuthToken?: string;
@Column({ nullable: true }) @Column({ nullable: true, select: false })
public plexToken?: string; public plexToken?: string;
@Column({ type: 'integer', default: 0 }) @Column({ type: 'integer', default: 0 })

View File

@@ -263,6 +263,7 @@ authRoutes.post('/jellyfin', async (req, res, next) => {
// Try to find deviceId that corresponds to jellyfin user, else generate a new one // Try to find deviceId that corresponds to jellyfin user, else generate a new one
let user = await userRepository.findOne({ let user = await userRepository.findOne({
where: { jellyfinUsername: body.username }, where: { jellyfinUsername: body.username },
select: { id: true, jellyfinDeviceId: true },
}); });
let deviceId = ''; let deviceId = '';