Per 《
新华成语词典》, derived from 《
老子》 chapter 58:
祸兮福之所倚,
福兮祸之所伏 — 'misfortune is what fortune leans upon; fortune is where misfortune crouches.' Pure Daoist dialectics — the same logic underlies the chengyu
塞翁失马 (the parable of the old man whose lost horse turns out to be a blessing, and whose returning horses turn out to be a curse, and so on).