5465 Total CVEs
26 Years
GitHub
README.md
Rendering markdown...
POC / presign.js JS
import { CreateBucketCommand, GetObjectCommand, S3Client } from "@aws-sdk/client-s3";
import { createPresignedPost as createPresignedPostSdk } from "@aws-sdk/s3-presigned-post";

const s3 = new S3Client({
  region: "eu-central-1",
  endpoint: "http://localhost:9000",
  forcePathStyle: true,
  credentials: {
    accessKeyId: "demo",
    secretAccessKey: "demodemodemodemo",
  },
});

export async function initService() {
  try {
    await s3.send(new CreateBucketCommand({ Bucket: "exploit-demo" }));
  }
  catch (e) {
    if (e.Code !== "BucketAlreadyOwnedByYou") {
      throw e;
    }
  }
}

export async function createPresignedPost(key, conditions) {
  return createPresignedPostSdk(s3, {
    Bucket: "exploit-demo",
    Key: key,
    Fields: {
      "Content-Type": "text/plain",
    },
    Conditions: conditions,
    Expires: 60,
  });
}

export async function getKeyBuffer(key) {
  const res = await s3.send(new GetObjectCommand({
    Bucket: "exploit-demo",
    Key: key,
  }));

  return [Buffer.concat(await Array.fromAsync(res.Body)), res.ContentType];
}