Malicious code has posed a severe threat to modern society. Delivering antivirus program to networks is an important task of a cybersecurity company. As the bandwidth resource in a company is limited and precious, cybersecurity companies have to make a tradeoff between the impact(i.e. the economic loss) of malicious codes and the bandwidth assigned to transmit the antivirus programs. This paper addresses the malicious code and bandwidth tradeoff(MCBT) problem. By developing a novel malicious code and antivirus program interacting model, the total loss, which is the sum of the bandwidth usage fee and the economic loss, is quantified. On this basis, the MCBT problem is modelled as a constrained optimization problem that we refer to as the MCBT model, where the independent variable stands for bandwidth, and the objective function stands for the total loss. Some optimal bandwidth is determined by solving the MCBT model. Based on this, we propose a heuristic algorithm named DOWNHILL, which outperforms random strategies. Finally, the influence of some factors on the optimal bandwidth and the corresponding optimal total loss is uncovered through numerical simulations. To our knowledge, this is the first time the MCBT problem is treated in this way. INDEX TERMS Cyber security, malicious code, bandwidth, node-level epidemic model, constrained optimization, tradeoff problem.