Form files: a dropped, stalled or endless upload is aborted and frees its slot, attempt key and buffers
Security review of 1.16.0 (blocking): a request body that errored mid-file never resolved, leaking the concurrency slot and the attempt key. Also: idle and request timeouts (submit.idleTimeoutMs / timeoutMs), ImmutableId preference on every Graph draft call, the remaining total in the too-large message, files sent to a form without a File field are refused and logged. Co-Authored-By: Claude Fable 5.2 <[email protected]>
This commit is contained in:
co-authored by
Claude Fable 5.2
parent
cd74d7decb
commit
e24c918d4b
@@ -100,7 +100,8 @@ const permissionDetail =
|
||||
*/
|
||||
export async function sendLargeGraphMail(attachments: GraphAttachment[], { cleanupDelaysMs = [2000, 5000, 15_000, 60_000], fetchImpl, log, message, sender, token }: LargeArgs): Promise<GraphLargeResult> {
|
||||
const base = `https://graph.microsoft.com/v1.0/users/${encodeURIComponent(sender)}`
|
||||
const auth = { Authorization: `Bearer ${token}` }
|
||||
// Every call on the draft asks for (and addresses it by) its immutable id — the id that survives the move to Sent Items.
|
||||
const auth = { Authorization: `Bearer ${token}`, Prefer: 'IdType="ImmutableId"' }
|
||||
const json = { ...auth, 'Content-Type': 'application/json' }
|
||||
const describe = async (res: Response) => `${res.status} ${(await res.text().catch(() => '')).slice(0, 300)}`
|
||||
|
||||
@@ -121,7 +122,7 @@ export async function sendLargeGraphMail(attachments: GraphAttachment[], { clean
|
||||
// An immutable id stays the same when the draft moves to Sent Items — that is how the copy is found again.
|
||||
const created = await fetchImpl(`${base}/messages`, {
|
||||
body: JSON.stringify(message),
|
||||
headers: { ...json, Prefer: 'IdType="ImmutableId"' },
|
||||
headers: json,
|
||||
method: 'POST',
|
||||
})
|
||||
if (created.status === 401 || created.status === 403) {
|
||||
@@ -180,7 +181,7 @@ export async function sendLargeGraphMail(attachments: GraphAttachment[], { clean
|
||||
for (const delay of cleanupDelaysMs) {
|
||||
await sleep(delay)
|
||||
try {
|
||||
const look = await fetchImpl(`${base}/messages/${encodeURIComponent(sentId)}?$select=isDraft`, { headers: { ...auth, Prefer: 'IdType="ImmutableId"' } })
|
||||
const look = await fetchImpl(`${base}/messages/${encodeURIComponent(sentId)}?$select=isDraft`, { headers: auth })
|
||||
if (look.status === 404) {return 'deleted'}
|
||||
if (look.ok && ((await look.json()) as { isDraft?: boolean }).isDraft === false) {
|
||||
if (await remove(sentId)) {return 'deleted'}
|
||||
|
||||
Reference in New Issue
Block a user