Synonyms for "walking on thin ice"

Solution 1:

Consider tempt fate or tempt the devil.

Also, "tempt the fates": Take a severe risk, as in It's tempting fate to start up that mountain so late in the day, or Patrice thought driving that old car was tempting the fates; it was sure to break down.

This expression uses tempt in the sense of “test in a way that involves risk or danger.” Earlier idioms with a similar meaning were tempt God, dating from the 1300s, and tempt fortune, first recorded in 1603, with fate appearing about 1700. (source Dictionary.com)

Solution 2:

Perhaps this from the OED Online 'fire' definition:

P2. With a verb.
....
g. to play (also mess) with fire: to take unnecessary or foolish risks; to invite trouble. Often paired with to get burned, expressing inevitability that trouble will result from a particular action.