Skip to main content

Business information leak - Financial Information


Protection of sensitive financial information from unauthorized access or disclosure


  • Usage of TypeScript for adding static typing to JavaScript development
  • Usage of Express for building web applications and handling HTTP requests


Non compliant code

import express from 'express';

const app = express();

app.get('/payment', (req, res) => {
const mail = req.query.mail;
const paymentRef = req.query.paymentRef;
const totalValue = req.query.totalValue;
const productInfo = req.query.productInfo;
const collectorsLineOfBusiness = req.query.collectorsLineOfBusiness;
const payersRole = req.query.payersRole;

// Process the payment and return a response
// ...

res.send('Payment processed successfully');

app.listen(3000, () => {
console.log('Server started on port 3000');

The vulnerability in this code is that it exposes sensitive business information through the URL query parameters. The code retrieves various pieces of sensitive information such as mail, payment reference, total value, product information, collector's line of business, and payer's role from the query parameters.

Since query parameters are part of the URL, they can be easily accessed and viewed by anyone who has access to the URL. This means that an attacker can potentially obtain sensitive business information by simply accessing the URL with the appropriate query parameters.

This vulnerability can lead to a business information leak, specifically financial information. Attackers can use this leaked information to create new attack vectors, such as launching targeted phishing attacks or identity theft.

To mitigate this vulnerability, it is recommended to establish controls to ensure that the sensitive information is only accessible to authorized individuals. This can be achieved by implementing proper authentication and authorization mechanisms to restrict access to the sensitive information.


  • Remove the route handler for '/payment' or update it to handle the sensitive information securely.
  • Implement authentication and authorization mechanisms to ensure that only authorized users can access the sensitive information.
  • Encrypt the sensitive information before storing it or transmitting it over the network.
  • Use secure protocols (e.g., HTTPS) for transmitting the sensitive information.
  • Implement input validation and sanitization to prevent any malicious input from being processed.
  • Implement logging and monitoring to detect any unauthorized access or suspicious activities related to the sensitive information.
  • Regularly update and patch the dependencies used in the application to address any known vulnerabilities.

Compliant code

import express from 'express';

const app = express();

app.get('/payment', (req, res) => {
// Authenticate and authorize the user before accessing the sensitive information
// ...

// Retrieve the encrypted sensitive information
const encryptedMail = req.query.mail;
const encryptedPaymentRef = req.query.paymentRef;
const encryptedTotalValue = req.query.totalValue;
const encryptedProductInfo = req.query.productInfo;
const encryptedCollectorsLineOfBusiness = req.query.collectorsLineOfBusiness;
const encryptedPayersRole = req.query.payersRole;

// Decrypt the sensitive information
const mail = decrypt(encryptedMail);
const paymentRef = decrypt(encryptedPaymentRef);
const totalValue = decrypt(encryptedTotalValue);
const productInfo = decrypt(encryptedProductInfo);
const collectorsLineOfBusiness = decrypt(encryptedCollectorsLineOfBusiness);
const payersRole = decrypt(encryptedPayersRole);

// Process the payment securely and return a response
// ...

res.send('Payment processed successfully');

app.listen(3000, () => {
console.log('Server started on port 3000');

// Function to decrypt the sensitive information
function decrypt(encryptedData: string): string {
// Implement decryption logic here
// ...
return decryptedData;

The fixed code is written in TypeScript and uses the Express framework to create a server. It addresses the vulnerability by implementing controls to ensure that sensitive information is only accessible to authorized individuals.

The code starts by importing the necessary dependencies, including the Express module. It then creates an instance of the Express application.

The vulnerable route /payment is secured by implementing authentication and authorization mechanisms before accessing the sensitive information. This step ensures that only authenticated and authorized users can proceed.

The encrypted sensitive information is retrieved from the request query parameters. These parameters include mail, paymentRef, totalValue, productInfo, collectorsLineOfBusiness, and payersRole. These values are encrypted and need to be decrypted before further processing.

The code then calls the decrypt function to decrypt each of the encrypted values. The decrypt function is a placeholder that needs to be implemented with the appropriate decryption logic. It takes an encrypted string as input and returns the decrypted string.

After decrypting the sensitive information, the code can securely process the payment and perform any necessary operations. Finally, a success response is sent back to the client.

The server listens on port 3000, and a message is logged to the console indicating that the server has started.

It's important to note that the code provided is a simplified example and does not include all the necessary security measures. In a real-world scenario, additional security measures such as input validation, encryption key management, and secure storage of sensitive information would need to be implemented to ensure the overall security of the system.