It's tough to find synonyms for whole phrases as opposed to single words. I'm trying to think of at least a couple for "walking on thin ice." So far the only one I've come up with is "playing a dangerous game" and it's a little more on the...harsh? side than what I'd wanted. Can anyone else think of anything?
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)
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.
flirt with danger/disaster
To do something that you know you should not do and that may cause you serious trouble.
walk on eggshells
(idiomatic) To be overly careful in dealing with a person or situation because they get angry or offended very easily; to try very hard not to upset someone or something.
(idiomatic) To be careful and sensitive, in handling very sensitive matters.
At times you'll feel like you're walking on eggshells, with no idea what to say or do . If you say the wrong thing, it's like setting off a volcano. Even keeping quiet at the wrong times can prove fatal.
Fly too close to the sun, (and you'll burn)
Fly too close to the ocean, (and you'll drown)
These are quotes borrowed and changed accordingly from the story of Icarus.
The day they were to leave, Daedalus lectured Icarus one last time, “Now son, remember, you must be cautious when we fly. Fly too close to the ocean and your wings will become too heavy with the water that sprays off the waves. Fly too close to the sun and the wax will melt and you will lose feathers. Follow my path closely and you’ll be fine.”
Variations of these can be seen in popular films and TV shows. For example, a quote from Breaking Bad:
"I've been thinking about Victor. All this time, I was sure that Gus did what he did to send me a message. Maybe there's another reason. Victor trying to cook that batch on his own, taking liberties that weren't his to take. Maybe he flew too close to the sun and got his throat cut." ― Walter White