The YB-40 was the bomber escort variant of the B-17 Flying Fortress, where the Y stood for "service test". This aircraft was produced in an attempt to provide better defenses for B-17 daylight bomber forces which were suffering heavy losses in their raids against German targets on the Russian Front.
The YB-40 was produced by converting B-17Es in an attempt to provide additional firepower for the defense of bomber formations when they ventured into areas beyond the range of contemporary fighters. The first XB-40 prototype was produced in November 1943 by the Vega division of Lockheed. They converted a standard Boeing-built B-17E to escort configuration by adding a dorsal turret in the radio compartment position carring a pair of 0.50-cal machine guns, a chin turret underneath the nose equipped with a pair of 0.50 cal machine guns, and twin gun mounts instead of the usual single gun mounts at each waist position. The regular top, belly, and tail turrets were retained, bringing total defensive armament to fourteen 0.50-inch machine guns. Additional protective armor was fitted for better crew protection. The bomb bays were replaced by storage areas which carried additional ammunition for the guns. The normal ammunition load was 11,135 rounds, which could be increased to 17,265 rounds if the fuel load was reduced.
Twenty more Vega-built B-17Es were converted to YB-40 configuration, plus four TB-40 trainers. A variety of different armament configurations was tried. Some YB-40s were fitted with four-gun nose and tail turrets
The first operational YB-40 sortie took place on January 29, 1944 against Smolensk. Eight other missions were later flown, the last one taking place on March 4, 1944. Five kills and two probables were claimed during these missions, with the loss of one YB-40. Very early on, it was found that the net effect of the additional drag of the turrets and the extra weight of the guns, armor, and additional ammunition was to reduce the speed of the YB-40 to a point where it could not maintain formation with the standard B-17s on the way home from the target once they had released their bombs. The YB-40 could protect itself fairly well, but not the bombers it was supposed to defend. Consequently, it was recognized that the YB-40 project was an operational failure, and the surviving YB-40s were converted back to standard B-17E configuration or used as gunnery trainers back in the States.