Normally basis is defined as the diference between rates in cash market minus those in derivative market. Then why is CDS basis = CDS spread - Z spread (derivative market - cash market)

I assume that’s because under “normal market conditions” the difference between the CDS spread and the Z spread or asset swap spread (the CDS basis) should be zero unlike the classic “basis” for futures markets which can be either positive or negative.

Both spreads are reflective of credit risk and CDS spread is explicitly the cost for hedging credit risk.

A negative basis indicates that one can make easy money in an arbitrage trade where Z spread is higher for bonds (and price lower) while selling protection on CDS whose spread is lower (and price higher) waiting that the difference between spread converge toward zero.

This is equivalent to buying the bond and earn the spread while selling (and not buying) credit protection on the same bond.

Trading the negative CDS spread basis is like being insured against damage caused by fire in your house and be paid for that by the insurance company.

In sum the CDS should not be negative and making this risk free arbitrage trade involves buying the (negative) CDS basis, which goes against the “convention”.

Could someone kindly elaborate this relationship?