{
 "name": "Codzee head-to-head answer key",
 "date": "2026-11-30",
 "issues": 87,
 "pull_requests": [
  {
   "original_pr": 1,
   "retest_pr": "https://github.com/williams2019495/shopflow-api-retest/pull/10",
   "title": "Customer order history and profile updates",
   "issues": [
    {
     "comment": "GET /customers/:customerId/orders only checks that x-customer-id is present and never compares it with req.params.customerId, so any signed-in customer can read another customer's order history by changing the id in the path.",
     "severity": "Critical",
     "category": "security"
    },
    {
     "comment": "PATCH /customers/:customerId never calls currentCustomer() or checks ownership, so anyone (even without x-customer-id) can change any customer's name or email, which enables account takeover through the email address.",
     "severity": "Critical",
     "category": "security"
    },
    {
     "comment": "Pagination offset is computed as page * PAGE_SIZE while page defaults to 1, so the default request skips the ten newest orders and a customer with ten or fewer orders gets an empty list; it should be (page - 1) * PAGE_SIZE.",
     "severity": "High",
     "category": "bug"
    },
    {
     "comment": "The page query parameter is passed through Number() with no validation, so ?page=abc yields NaN (empty list, page: null, 200 OK) and negative or fractional values return wrong slices instead of a 400.",
     "severity": "Low",
     "category": "bug"
    },
    {
     "comment": "PATCH /customers/:customerId stores any string as email or name with no validation, so an empty string or a non-email value can replace the customer's email address.",
     "severity": "Low",
     "category": "bug"
    }
   ]
  },
  {
   "original_pr": 2,
   "retest_pr": "https://github.com/williams2019495/shopflow-api-retest/pull/11",
   "title": "Let customers stack up to three coupons",
   "issues": [
    {
     "comment": "POST /products/coupons has no authentication or admin check, so any caller can create a 100%-off coupon (or rewrite an existing one) and then redeem it on POST /orders for free goods.",
     "severity": "Critical",
     "category": "security"
    },
    {
     "comment": "stackedTotals deduplicates with new Set(codes) before upper-casing, so ['WELCOME10','welcome10','Welcome10'] survives as three entries and the same coupon is applied three times, contradicting 'duplicates are ignored'.",
     "severity": "High",
     "category": "bug"
    },
    {
     "comment": "stackedTotals sums each coupon's percent of the full subtotal with no cap, so discountCents can exceed subtotalCents and totalCents goes negative (e.g. two 60% campaign coupons).",
     "severity": "High",
     "category": "bug"
    },
    {
     "comment": "POST /products/coupons only checks typeof percentOff === 'number' and never checks minSubtotalCents, so negative or >100 percentages and non-numeric minimums are stored and corrupt order pricing (a negative percent raises totals, >100 makes them negative).",
     "severity": "High",
     "category": "data"
    },
    {
     "comment": "createCoupon writes COUPONS[code.toUpperCase()] without checking for an existing entry, so posting 'welcome10' silently overwrites the built-in WELCOME10/BIGBASKET rules for every later order.",
     "severity": "Medium",
     "category": "bug"
    },
    {
     "comment": "The returned applied field is the full deduplicated input list, so unknown codes and coupons skipped for minSubtotalCents are stored on the order and reported as applied.",
     "severity": "Low",
     "category": "api"
    },
    {
     "comment": "The three-coupon limit is applied with slice(0, MAX_COUPONS) before codes are validated and the zod schema has no .max(3), so extra codes are silently dropped instead of rejected and invalid codes can push a valid fourth code out.",
     "severity": "Low",
     "category": "bug"
    },
    {
     "comment": "Replacing couponCode with couponCodes in the CreateOrder schema means existing clients that still send couponCode get a 201 with the field silently stripped and no discount, rather than an error.",
     "severity": "Low",
     "category": "api"
    }
   ]
  },
  {
   "original_pr": 3,
   "retest_pr": "https://github.com/williams2019495/shopflow-api-retest/pull/12",
   "title": "Mark orders paid from the payment provider's webhook",
   "issues": [
    {
     "comment": "PAYMENT_WEBHOOK_SECRET falls back to a hardcoded whsec_... literal, so when the env var is unset anyone who has the source can sign a payment.succeeded event and mark any order paid without paying.",
     "severity": "Critical",
     "category": "security"
    },
    {
     "comment": "The HMAC is computed over JSON.stringify(req.body) instead of the raw request bytes, so any difference in whitespace, key order or escaping makes genuine provider webhooks fail with 401 and orders are never marked paid.",
     "severity": "High",
     "category": "bug"
    },
    {
     "comment": "payment.succeeded sets order.status = 'paid' regardless of current status, so a late or retried success marks a cancelled/refunded order (whose stock was already released) as paid.",
     "severity": "High",
     "category": "bug"
    },
    {
     "comment": "payment.refunded sets status to 'cancelled' without calling release(order.lines), so refunded orders keep their stock reserved permanently (and shipped orders are cancelled too).",
     "severity": "Medium",
     "category": "bug"
    },
    {
     "comment": "The signature covers only the body with no timestamp or event-id check, so a captured signed event can be replayed indefinitely (e.g. replaying payment.succeeded after a refund).",
     "severity": "Medium",
     "category": "security"
    },
    {
     "comment": "The signature is compared with != instead of crypto.timingSafeEqual, leaking timing information about the expected HMAC.",
     "severity": "Low",
     "category": "security"
    },
    {
     "comment": "console.log writes the entire req.body payment payload to logs on every event, exposing any customer or payment fields the provider sends.",
     "severity": "Low",
     "category": "security"
    }
   ]
  },
  {
   "original_pr": 4,
   "retest_pr": "https://github.com/williams2019495/shopflow-api-retest/pull/13",
   "title": "Express checkout: hold the card before taking stock",
   "issues": [
    {
     "comment": "POST /orders already calls reserve(lines), but expressCheckout re-checks stock and decrements products.stock again, so every checkout takes the stock twice (and an order for the last unit fails checkout); a declined hold also leaves the order's original reservation in place, so the 'declined card never takes stock' promise does not hold.",
     "severity": "High",
     "category": "bug"
    },
    {
     "comment": "expressCheckout never checks order.status, so calling it again on a paid (or cancelled/shipped) order places a new hold, takes stock again and captures a second payment, double-charging the customer.",
     "severity": "High",
     "category": "bug"
    },
    {
     "comment": "The stock check runs before await gateway.hold() and the decrement after it without re-checking, so two concurrent checkouts for the last unit both pass and stock goes negative while both are charged.",
     "severity": "Medium",
     "category": "concurrency"
    },
    {
     "comment": "If gateway.capture(holdId) rejects, the stock already decremented is never restored, the hold stays open and the order stays pending, so a retry takes more stock and places another hold.",
     "severity": "Medium",
     "category": "bug"
    },
    {
     "comment": "Stock is checked per line rather than per product, so an order with two lines for the same productId can pass each check individually and drive stock below zero.",
     "severity": "Low",
     "category": "bug"
    }
   ]
  },
  {
   "original_pr": 5,
   "retest_pr": "https://github.com/williams2019495/shopflow-api-retest/pull/14",
   "title": "Admin login with signed tokens for the back office",
   "issues": [
    {
     "comment": "verifyToken skips signature verification when the token header says alg: 'none', so anyone can forge an unsigned token and read every order from GET /admin/orders.",
     "severity": "Critical",
     "category": "security"
    },
    {
     "comment": "TOKEN_SECRET falls back to the hardcoded 'dev-admin-secret' when ADMIN_TOKEN_SECRET is unset, so anyone who knows it can sign valid admin tokens.",
     "severity": "Critical",
     "category": "security"
    },
    {
     "comment": "ADMINS falls back to the password 'changeme' for both ops@ and help@ accounts when ADMIN_PASSWORD/SUPPORT_PASSWORD are unset, so anyone can log in as admin.",
     "severity": "Critical",
     "category": "security"
    },
    {
     "comment": "ADMINS[email] resolves inherited keys, so email '__proto__'/'constructor'/'toString' with no password matches (undefined === undefined) and issueToken returns a valid token.",
     "severity": "Critical",
     "category": "security"
    },
    {
     "comment": "verifyToken never compares claims.exp with the current time, so tokens never expire despite the one-working-day TTL.",
     "severity": "High",
     "category": "security"
    },
    {
     "comment": "GET /admin/orders never checks claims.role, so a 'support' token gets the admin-only list of every order.",
     "severity": "High",
     "category": "security"
    },
    {
     "comment": "verifyToken calls JSON.parse on the header and payload without try/catch, so a malformed bearer token produces a 500 instead of returning null/401.",
     "severity": "Low",
     "category": "bug"
    },
    {
     "comment": "POST /admin/login returns 404 no_such_admin for unknown emails and 401 wrong_password for known ones, letting callers enumerate back-office accounts.",
     "severity": "Low",
     "category": "security"
    },
    {
     "comment": "Admin passwords are kept in plaintext and compared with !==, a non-constant-time comparison that leaks timing.",
     "severity": "Low",
     "category": "security"
    }
   ]
  },
  {
   "original_pr": 6,
   "retest_pr": "https://github.com/williams2019495/shopflow-api-retest/pull/15",
   "title": "Password reset by email",
   "issues": [
    {
     "comment": "newToken() builds the reset token from Math.random() with only ~8 base-36 characters, a non-cryptographic and low-entropy secret that can be predicted or brute-forced to take over accounts.",
     "severity": "Critical",
     "category": "security"
    },
    {
     "comment": "The reset link is passed to sendEmail, which console.logs the full body, so live reset tokens are written to application logs and anyone with log access can reset any password.",
     "severity": "High",
     "category": "security"
    },
    {
     "comment": "/confirm never checks reset.createdAt, so reset tokens never expire.",
     "severity": "High",
     "category": "security"
    },
    {
     "comment": "/confirm never deletes the token after a successful reset, so a used link can be reused to change the password again.",
     "severity": "High",
     "category": "security"
    },
    {
     "comment": "/request returns 404 no_account_for_email for unknown addresses and 200 for known ones, letting anyone enumerate customer emails.",
     "severity": "Medium",
     "category": "security"
    },
    {
     "comment": "The new password is written to a module-private passwords Map that nothing reads, so a successful reset does not change any credential used for login.",
     "severity": "Medium",
     "category": "bug"
    },
    {
     "comment": "passwords.set stores the submitted password in plaintext instead of a salted hash.",
     "severity": "Medium",
     "category": "security"
    },
    {
     "comment": "sendEmail only writes to the console, so no email is ever sent even though the endpoint replies { sent: true }.",
     "severity": "Low",
     "category": "bug"
    },
    {
     "comment": "Each /request for a known email adds a new entry to resets with no rate limit, cleanup or invalidation of earlier tokens, so the map grows without bound.",
     "severity": "Low",
     "category": "perf"
    }
   ]
  },
  {
   "original_pr": 7,
   "retest_pr": "https://github.com/williams2019495/shopflow-api-retest/pull/16",
   "title": "Import products from a supplier feed URL",
   "issues": [
    {
     "comment": "writeFile(path.join(IMAGE_DIR, feed.imageName)) uses a file name from the remote feed, so '../../src/app.ts' escapes public/images and overwrites any file the process can write with attacker-chosen bytes.",
     "severity": "Critical",
     "category": "security"
    },
    {
     "comment": "fetch(feedUrl) and fetch(feed.imageUrl) request arbitrary caller/feed-supplied URLs with no scheme or host allowlist, enabling SSRF to loopback, metadata and internal services.",
     "severity": "High",
     "category": "security"
    },
    {
     "comment": "/imports is mounted with no authentication or role check although it is meant for merchandising, so anyone can create products and trigger the server-side fetches and file writes.",
     "severity": "High",
     "category": "security"
    },
    {
     "comment": "The async handler has no try/catch and Express 4 does not forward rejected promises, so a failed fetch, invalid JSON or failed write leaves the request hanging and produces an unhandled rejection that can crash the process.",
     "severity": "High",
     "category": "bug"
    },
    {
     "comment": "Feed fields are stored unvalidated: a missing or string price gives priceCents NaN, negative prices are accepted, name can be undefined and stock can be negative or a string, all of which flow into order totals.",
     "severity": "Medium",
     "category": "data"
    },
    {
     "comment": "products.set runs before the image download and write, so if the image step fails the product stays in the catalogue half-imported and a retry creates a duplicate.",
     "severity": "Medium",
     "category": "bug"
    },
    {
     "comment": "public/images does not exist in the repo and writeFile does not create directories, so any import with an image fails with ENOENT.",
     "severity": "Medium",
     "category": "bug"
    },
    {
     "comment": "Both downloads are buffered fully into memory (arrayBuffer/json) with no size limit or timeout, so a large supplier response can exhaust server memory.",
     "severity": "Medium",
     "category": "perf"
    },
    {
     "comment": "Neither download checks response.ok, so a 404/500 error page is saved as the product image and the import still returns 201.",
     "severity": "Low",
     "category": "bug"
    },
    {
     "comment": "The image fetch never checks response.ok, so an HTTP error page from the supplier is saved as the product image and the import still returns 201.",
     "severity": "Medium",
     "category": "bug"
    }
   ]
  },
  {
   "original_pr": 8,
   "retest_pr": "https://github.com/williams2019495/shopflow-api-retest/pull/17",
   "title": "Partner API keys for reading customer orders",
   "issues": [
    {
     "comment": "GET /partners/orders never restricts results to partner.customerIds, so any valid key can read any customer's orders by passing customerId, or every order by omitting it.",
     "severity": "Critical",
     "category": "security"
    },
    {
     "comment": "POST /partners has no authentication although it is meant for the admin tool, so anyone can mint a working partner API key with arbitrary customerIds.",
     "severity": "Critical",
     "category": "security"
    },
    {
     "comment": "console.log writes the full newly issued apiKey to logs, so anyone with log access can act as that partner.",
     "severity": "Medium",
     "category": "security"
    },
    {
     "comment": "partners.set(name, ...) keys partners by an unvalidated name, so re-posting an existing name silently replaces that partner's key and customers (locking out the real partner) and a missing name is stored as 'undefined'.",
     "severity": "Medium",
     "category": "bug"
    },
    {
     "comment": "partnerFor compares API keys with == in a linear scan, a non-constant-time comparison.",
     "severity": "Low",
     "category": "security"
    }
   ]
  },
  {
   "original_pr": 9,
   "retest_pr": "https://github.com/williams2019495/shopflow-api-retest/pull/18",
   "title": "Browser sessions and CORS for the new storefront",
   "issues": [
    {
     "comment": "app.use(cors) is registered after the /health, /products and /orders routes, which end the response, so those responses never get CORS headers and the storefront cannot call the API.",
     "severity": "High",
     "category": "bug"
    },
    {
     "comment": "cors() reflects any request Origin into Access-Control-Allow-Origin together with Allow-Credentials: true, so any website can make credentialed requests and read the responses; there is no storefront/preview allowlist.",
     "severity": "High",
     "category": "security"
    },
    {
     "comment": "startSession stores the raw customerId in sf_session unsigned and sessionCustomer returns it as the signed-in customer, so a client can set sf_session=cus_00001 and impersonate any customer once these helpers are used.",
     "severity": "High",
     "category": "security"
    },
    {
     "comment": "The sf_session cookie is set for 30 days without httpOnly or secure, so it is readable by page scripts and can be sent over plain HTTP.",
     "severity": "Low",
     "category": "security"
    },
    {
     "comment": "The /sf_session=([^;]+)/ regex is not anchored to a cookie boundary, so a cookie such as old_sf_session=... is matched instead of (or in place of) sf_session.",
     "severity": "Low",
     "category": "bug"
    }
   ]
  },
  {
   "original_pr": 10,
   "retest_pr": "https://github.com/williams2019495/shopflow-api-retest/pull/19",
   "title": "Courier webhook: mark orders shipped or returned",
   "issues": [
    {
     "comment": "SHIPPING_SECRET falls back to '' when SHIPPING_WEBHOOK_SECRET is unset, so the HMAC key is empty and anyone can forge courier events that cancel orders and restock inventory.",
     "severity": "Critical",
     "category": "security"
    },
    {
     "comment": "The expected signature is computed over JSON.stringify(req.body) instead of the raw bytes the courier signed, so genuine courier calls with different whitespace or key order are rejected with 401.",
     "severity": "High",
     "category": "bug"
    },
    {
     "comment": "parcel.returned adds stock back without checking order.status, so courier retries, or a return for an order already cancelled via /orders/:id/cancel, restock the same items again and inflate inventory.",
     "severity": "High",
     "category": "bug"
    },
    {
     "comment": "parcel.shipped sets status = 'shipped' regardless of current status, so a late shipped event reopens a cancelled/returned order (whose stock was released) and an unpaid pending order can be marked shipped.",
     "severity": "Medium",
     "category": "bug"
    },
    {
     "comment": "The documented x-courier-timestamp header is never read or signed, so a captured signed event can be replayed at any time.",
     "severity": "Medium",
     "category": "security"
    },
    {
     "comment": "The signature is compared with !== instead of timingSafeEqual, leaking timing information.",
     "severity": "Low",
     "category": "security"
    }
   ]
  },
  {
   "original_pr": 11,
   "retest_pr": "https://github.com/williams2019495/shopflow-api-retest/pull/20",
   "title": "Gift cards: sell and redeem against an order",
   "issues": [
    {
     "comment": "POST /gift-cards creates a card for any amountCents with no authentication or payment verification, so anyone can mint gift cards and redeem them for free goods.",
     "severity": "Critical",
     "category": "security"
    },
    {
     "comment": "/redeem computes amount from card.balanceCents, then awaits recordRedemption (~200 ms) before decrementing, so concurrent redemptions both spend the same balance (card goes negative, orders marked paid).",
     "severity": "Critical",
     "category": "concurrency"
    },
    {
     "comment": "/redeem never checks that the order is pending, so a cancelled (or already paid) order with a positive total can be charged to the card and flipped to 'paid'.",
     "severity": "High",
     "category": "bug"
    },
    {
     "comment": "console.log('gift card sold', card) and recordRedemption log the full gift card code, which is the only secret protecting the balance.",
     "severity": "Medium",
     "category": "security"
    },
    {
     "comment": "After a partial redemption the order stays pending, and POST /orders/:id/cancel then cancels it and releases stock without refunding the amount taken from the gift card.",
     "severity": "Medium",
     "category": "bug"
    },
    {
     "comment": "recordRedemption only sleeps and logs; nothing is written to a finance ledger even though the PR says redemptions are recorded there.",
     "severity": "Low",
     "category": "bug"
    }
   ]
  },
  {
   "original_pr": 12,
   "retest_pr": "https://github.com/williams2019495/shopflow-api-retest/pull/21",
   "title": "Passwordless sign-in with a six-digit email code",
   "issues": [
    {
     "comment": "/verify has no attempt limit, lockout or rate limit, so an attacker can try all 1,000,000 six-digit codes against a customer id (ids are sequential) and sign in as them.",
     "severity": "Critical",
     "category": "security"
    },
    {
     "comment": "/start console.logs the plaintext sign-in code with the email, so anyone with log access can sign in as any customer, defeating the hashed storage.",
     "severity": "High",
     "category": "security"
    },
    {
     "comment": "/verify never checks challenge.expiresAt, so codes stay valid indefinitely instead of expiring after five minutes.",
     "severity": "High",
     "category": "security"
    },
    {
     "comment": "/verify does not delete the challenge on success, so the same code can be used to sign in repeatedly.",
     "severity": "High",
     "category": "security"
    },
    {
     "comment": "/verify only returns { signedIn: true, customerId } and issues no session cookie or token, so nothing proves the sign-in on later requests despite the 'we start a session' comment.",
     "severity": "Medium",
     "category": "bug"
    },
    {
     "comment": "/verify requires the internal customerId, but /start only takes an email and returns { sent: true }, so a real customer has no way to learn the id needed to finish sign-in.",
     "severity": "Medium",
     "category": "bug"
    },
    {
     "comment": "/start never sends an email; it only logs the code, so the advertised email delivery is not implemented.",
     "severity": "Low",
     "category": "bug"
    }
   ]
  },
  {
   "original_pr": 13,
   "retest_pr": "https://github.com/williams2019495/shopflow-api-retest/pull/22",
   "title": "Sync stock counts from the warehouse",
   "issues": [
    {
     "comment": "The HMAC is computed over JSON.stringify(req.body) rather than the raw bytes the warehouse signed, so genuine pushes whose serialization differs are rejected with 401 and stock silently drifts.",
     "severity": "High",
     "category": "bug"
    },
    {
     "comment": "sentAt is documented but never read and product.stock = stock is applied unconditionally, so a delayed, retried or replayed older push overwrites a newer stock count (e.g. restoring sold-out stock).",
     "severity": "High",
     "category": "bug"
    },
    {
     "comment": "timingSafeEqual throws a RangeError when the buffers differ in length, so a missing, short or non-hex x-warehouse-signature produces a 500 instead of the 401 bad_signature response.",
     "severity": "Medium",
     "category": "bug"
    },
    {
     "comment": "stock is written without type or range validation, so a missing, string, negative or fractional value is stored and reserve()'s stock < quantity check then lets the product be oversold.",
     "severity": "Medium",
     "category": "data"
    },
    {
     "comment": "The stock sync writes the warehouse count as an absolute stock value, overwriting units already reserved by pending orders, so reserved stock is resold and can go negative.",
     "severity": "High",
     "category": "data"
    }
   ]
  }
 ]
}