CVE-2012-3436 (vulnerable 0.6.0 - fixed 1.2.2)

Short description: Denial of service (server) using ships on half tiles and landscaping.

Official CVE-2012-3436 entry at cve.mitre.org.

Related bug reports:

Related commits:

Patches: (sometimes more fuzz is needed to apply them)

Denial of service using ships on half tiles and landscaping.

Simple steps to reproduce the issue, and show the severity:

  1. start a new game. For this reproduction you do not need to start a server; you can see the crash locally, but due to the nature of OpenTTD the crash will also happen on the server you're playing on with multiplayer.
  2. build some horizontal or vertical track at the coast, so that half of the tile remains water or coast. The tile should either have one corner raised with flat water on one half tile (case 1) or two adjacent corners raised with coast on the sloped half tile (case 2)
  3. build a ship depot, a ship and a dock at the coast, and start the ship
  4. obstruct the path of the ship in a way so that it enters the tile with half railtrack and half water
  5. landscape the tile by raising the water corner while the ship is on it (only needed in case 1)
  6. both cases will make the ship end up on land
  7. remove the track using the "remove track" tool while the ship is on the tile
  8. server segfaults due to NULL pointer dereference.
The problem is caused by incorrectly handling the water/coast aspect of tiles which also have railtracks on one half. The fix adds the correct checks to the landscaping and movement code.

If you try to reproduce this with the patch applied you'll see that, in case 1, step 5 will deny the terraforming and in case 2 the ship simply won't try to enter the coast tile.

This bug was triggered incidentally by a user playing online when landscaping near a ship. We have not seen any signs of this bug being exploited forcefully.