The Boeing YB-40 Flying Fortress was a modification of the United States B-17 Flying Fortress bomber aircraft, converted to act as a heavily-armed escort for other bombers during World War II. At the time of its development, long-range fighter aircraft such as the P-51 Mustang were just entering quantity production, and thus were not yet available to accompany bombers all the way from England to Germany and back.
Work on the prototype, Project V-139, began in September, 1942 by converting the second production B-17F-1-BO built by Lockheed's Vega subsidiary. The first flight of the XB-40 was on 10 November 1942. The first order of 13 was made in October 1942. A follow-up order for 12 more was made in January, 1943. The modifications were performed by Douglas Aircraft at their Tulsa, Oklahoma center, and the first aircraft were completed by the end of March, 1943. Twenty service test aircraft were ordered, Vega Project V-140, as YB-40 along with four crew trainers designated TB-40. Because Vega had higher priority production projects, the YB-40/TB-40 assembly job was transferred to Douglas.
The aircraft differed from the standard B-17 in that a second dorsal turret was installed in the former radio compartment, just behind the bomb bay and forward of the ventral ball turret's location; the single .50-calibre (12.7 mm) Browning machine gun at each waist station was replaced by two mounted side-by-side, with a mount for each pair of these being very much like the tail gun setup in general appearance; and the bombardier's equipment was replaced with two .50-calibre machine guns in a Bendix designed "chin" turret. The existing "cheek" machine guns (on the sides of the forward fuselage at the bombardier station), initially removed from the configuration, were restored in England to provide a total of sixteen guns, and the bomb bay was converted to an ammunition magazine. Additional armor plating was installed to protect crew positions. The aircraft's gross weight was some 4000 pounds greater than a fully-armed B-17. An indication of the burden this placed on the YB-40 is that while the B-17F on which it was based was rated to climb to 20,000 feet in 25 minutes, the YB-40 was rated at 48 minutes. Part of the decreased performance was due to the weight increase, and part was due to the greater aerodynamic drag of the gun stations.
The YB-40's mission was to provide a heavily-gunned escort capable of accompanying the bombers all the way to the target and back. Overall the concept proved a failure because the YB-40 could not keep up with standard B-17Fs, particularly after they had dropped their bombs. Of the initial order of 13, one was damaged in a forced landing on the Isle of Lewis en route to England, and the remaining 12 were assigned to the 92nd Bomb Group (H) and designated the 327th Bomb Squadron. Between May 29 and August 16, 1943, the YB-40 flew 14 of the 19 combat missions scheduled by the 8th Air Force, although on the mission of June 26 all the YB-40s scheduled were unable to form up with the bombing squadron, and returned to base. Altogether of the 59 aircraft dispatched, 48 sorties were credited. Five German fighter kills and 2 probables (likely kills) were claimed on the 13 missions flown, and one YB-40 was lost, shot down by flak on the June 22 mission to Hüls, Germany. Tactics were revised on the final five missions by placing a pair of YB-40s in the lead element of the strike to protect the mission commander.
Despite the failure of the project as an operational aircraft, it led directly to modifications conspicuous on the final production variant of the B-17, the B-17G: