> Source: [sk35624](https://support.checkpoint.com/results/sk/sk35624)

# sk35624 - Preventing DNS cache poisoning when reusing source ports

| Property | Value |
|----------|-------|
| Solution ID | sk35624 |
| Date Created | 2008-07-27 |
| Last Modified | 2022-07-16 |
| Technical Level | General |
| Products | Security Gateway, Security Management Server, Multi-Domain Security Management Server |
| Versions | R82.10, R82, R81.20, R82.20 |

## Symptoms

- After applying the solution from [sk35623](http://supportcontent.checkpoint.com/solutions?id=sk35623) to overcome source port de-randomization caused by Hide-NAT, non-random source ports are still used in DNS Requests.

## Cause

Some DNS resolvers might use the exact same source port for different DNS Requests, regardless of the fact that the source port is chosen randomly.  

In such cases, the SmartDefense protection called "DNS request scrambling" / IPS protection called "Scrambling" changes the source port, but always to the same value. This is because the mechanism is based on NAT, in which a single DNS connection is always translated in the same way.

## Solution

Enable the "*Delete on Reply*" option for the DNS service.

When this option is enabled, each DNS connection terminates once the DNS Reply arrives, rather than waiting for the default UDP connection timeout (of \~40 seconds). As a result, consecutive DNS Requests using the same source port do not match existing connections. Instead, a new connection is opened for each request, and source ports are scrambled randomly.

### **Procedure:**

The necessary change can be performed *either* via the GuiDBedit Tool or the DBedit tool.

* Using *GuiDBedit Tool*:

  1. Close all SmartConsole windows (SmartDashboard, SmartView Tracker, SmartView Monitor, etc.).  

  2. Connect with [GuiDBedit Tool](http://supportcontent.checkpoint.com/solutions?id=sk13009) to Security Management Server.  

  3. In the upper left pane, go to ***Services*** - ***services*** .  

  4. In the upper right pane, select the ***domain-udp*** .  

  5. Press CTRL+F (or go to ***Search*** menu - ***Find*** ) - paste ***delete_on_reply*** - click on ***Find Next*** .  

  6. In the lower pane, right-click on the ***delete_on_reply*** - select ***Edit...*** - select "***true*** " - click on ***OK*** .  

  7. Save the changes: go to ***File*** menu - click on ***Save All*** .  

  8. Close the GuiDBedit Tool.  

  9. Connect with SmartDashboard to Security Management Server.  

  10. Install the policy onto the relevant Security Gateway / Cluster object.

  <br />

  <br />

* Using *DBedit* tool:

  1. Close all SmartConsole windows (SmartDashboard, SmartView Tracker, SmartView Monitor, etc.).  

  2. Connect to command line on Security Management Server and log in to Expert mode.  

  3. Connect with *dbedit* tool and run the following commands:

     ```
     [Expert@HostName]# dbedit
     dbedit> modify services domain-udp delete_on_reply true
     dbedit> print services domain-udp
     dbedit> quit -update_all
     ```

  4. Connect with SmartDashboard to Security Management Server.  

  5. Install the policy onto the relevant Security Gateway / Cluster object.

**Notes:**

"Delete on Reply" introduces a performance penalty. If the DNS resolver issues more than a few DNS Requests before the first DNS Reply arrives, these DNS Requests match the same connection, while the first DNS Reply to arrive deletes the connection.

Consequently, the subsequent DNS Replies are dropped, and connectivity issues may arise. These connectivity issues are normally prevented by built-in applicative timeout mechanisms (for example, a web browser generally issues several DNS Requests before it gives up resolving).

### Procedure for R80.20

1. To enable "Delete on Reply" (this kernel parameter controls "Delete on Reply" in both FireWall and SecureXL), do the following:

**On-the-fly** (the procedure will not survive reboot):

`fw ctl set int fwconn_dns_fexp_enable 1`

**Permanently** (see [sk26202](https://supportcenter.checkpoint.com/supportcenter/portal?eventSubmit_doGoviewsolutiondetails=&solutionid=sk26202)):

Add the following line to *$FWDIR/boot/modules/fwkern.conf* file and reboot:

`fwconn_dns_fexp_enable=1`

2. To change the "Delete on Reply" delay timeout*only* in SecureXL (the default value is the value of the UDP timeout - 40 secs), do the following:

**On-the-fly** (the procedure will not survive reboot)::

`sim ctl set int sim_fexp_selective_delay <Number of Seconds>`

**Permanently** (see [sk26202](https://supportcenter.checkpoint.com/supportcenter/portal?eventSubmit_doGoviewsolutiondetails=&solutionid=sk26202)):

Add this line to *$PPKDIR/conf/simkern.conf* file and reboot:

`sim_fexp_selective_delay=<Number of Seconds>`

To return to the default value, set the value of the kernel parameter *sim_fexp_selective_delay* to **0** (zero).

3. To disable the "Delete on Reply" feature only in SecureXL (fast expiry connection will be handled in FireWall):

**On-the-fly** (the procedure will not survive reboot):

`fw ctl set int cphwd_delete_on_response 1`

**Permanently** (see [sk26202](https://supportcenter.checkpoint.com/supportcenter/portal?eventSubmit_doGoviewsolutiondetails=&solutionid=sk26202)):

Add this line to *$FWDIR/boot/modules/fwkern.con*f file and reboot:

`cphwd_delete_on_response=1`

**Notes for R80.20**:

* Once the feature is enabled, DNS connections are marked for DELETE_ON_RESPONSE, and such connections will be deleted when the Security Gateway gets a reply packet. If there is no reply, the connection expires after the default UDP timeout (40 seconds).
* In SecureXL, the kernel parameter `sim_fexp_selective_delay` can be used to override the FireWall's default UDP timeout (40 seconds).
* If an Acceleration Card is installed on a Check Point appliance, the DNS connections will always be offloaded to SecureXL on the Host appliance, and never to SecureXL on the Acceleration Card.

**Related Solutions:**

* [sk35484 - Check Point response to DNS poisoning vulnerability CVE-2008-1447](http://supportcontent.checkpoint.com/solutions?id=sk35484)
* [sk35623 - Hide NAT cancels DNS source port randomization](http://supportcontent.checkpoint.com/solutions?id=sk35623)

<br />

**Notes for R80.30 and R80.40:**Contact Check Point support to provide you a script and instructions on how to run it. It must be run on your Management / MDS

---

# Agent Instructions

This content is from the Check Point Support Center (https://support.checkpoint.com), the official knowledge base for Check Point cybersecurity products.

## Navigating This Knowledge Base

- **Complete index**: [llms.txt](https://support.checkpoint.com/llms.txt)
- **All SK articles**: [SecureKnowledge Sitemap](https://support.checkpoint.com/sitemaps/secureknowledge-sitemap-index.xml)
- **SK article URL pattern**: `https://support.checkpoint.com/results/sk/{skId}`
- **Markdown responses**: AI bot User-Agents automatically receive `text/markdown` content
