The vulnerability lies in the creation of session transcript files with default permissions, which could be overly permissive depending on the system's umask. This could allow local users to access sensitive information within these transcript files. The analysis of the provided patch 095d522099653367e1b76fa5bb09d4ddf7c8a57c reveals the exact locations where this vulnerability is addressed.
Two functions were identified as being responsible for creating these files:
ensureSessionHeader in src/config/sessions/transcript.ts
ensureTranscriptFile in src/gateway/server-methods/chat.ts
In both functions, the patch modifies the file-writing operation (fs.promises.writeFile and fs.writeFileSync) to explicitly set the file mode to 0o600 (read/write for the owner only). This ensures that newly created transcript files are always created with secure permissions, regardless of the system's umask setting.
The functions ensureSessionHeader and ensureTranscriptFile are therefore the vulnerable functions, as they are directly responsible for the insecure file creation. During exploitation, a call to either of these functions would result in the creation of a transcript file with potentially insecure permissions.