I have an idiom and a proverb (saying) for you!
to play with fire
- to do something that could cause you great trouble later
- Example: "Don't you know you're playing with fire when you get involved with someone who's already married?"
Source: Cambridge Dictionary of American Idioms (via thefreedictionary.com)
There is a common saying using the same imagery:
If you play with fire, you get burned.
- If you do something dangerous, you will get hurt.
- Example: Joe said, "I have no sympathy for race-car drivers who get injured. They should know that if you play with fire, you get burned."
- Example: My mother always told us that experimenting with hard drugs was playing with fire.
Source: McGraw-Hill Dictionary of American Idioms and Phrasal Verbs (via thefreedictionary.com)
Idioms such as "to dance with death" and phrases like "there will be hell to pay" (or "there will be the devil to pay") are a bit too dramatic in this context.
I'm sure there is more, but I'll let others do some work as well.