In complex and interconnected banking systems, counterparty risk does not depend only on the risk of the immediate counterparty but also on the risk of others in the network of exposures. However, frequently, market participants do not observe the actual network of exposures. I propose an approach that incorporates this network of exposures, among other factors, in a valuation model of credit default swaps. The model-implied spreads are then used to retrieve the set of networks that are consistent with market spreads. The approach is illustrated with an application to the UK banking system.