#47731 [W&A-Insight] Offer Listings N+1 Query Performance Vulnerability
Description
// Single query to fetch offers (efficient)
const offers = (await Offer.findAll({
where: OffersWhereConditions,
order: [orderCondition],
limit: 15,
offset: (pageData.page - 1) * 15
}));
let offersWithUsers = [];
// N+1 query anti-pattern - loops through each offer
for (let offer of offers) {
// Query 1: Individual user lookup per offer
const user = await User.findOne({
where: { id: offer.user_id }
});
// Query 2: Individual input currency lookup per offer
const inputCurrency = await configModel.getCurrencyRow(offer.input_currency_id);
// Query 3: Individual target currency lookup per offer
const targetCurrency = await configModel.getCurrencyRow(offer.target_currency_id);
// Query 4: Individual deposit currency lookup per offer
const depositCurrency = await configModel.getCurrencyRow(offer.deposit_currency_id);
// Data assembly continues...
}Proof of Concept
Proof of Concept
Remediation
Previous#47729 [W&A-Insight] Insecure Token Storage in SessionStorageNext#47740 [W&A-Critical] Server-Side Request Forgery (SSRF) in `./src/pages/_app.tsx` via the Host header
Was this helpful?