[A humble request: If you can, please donate to help me carry on tracing word histories. Thank you.]
The phrase a fox in the henhouse, and its variants, designate a sly, treacherous or deceitful person, especially one who is secretly acting against the interests of the community or organisation to which he or she belongs.
—Cf. also the phrases the enemy within and fifth column.
An isolated early figurative use of the nouns fox and hens—and of the nouns wolf and sheep—occurred in the following from The Contre-League and ansvvere to certaine letters sent to the Maisters of Renes, by one of the League who termeth himselfe Lord of the valley of Mayne, and Gentleman of the late Duke of Guizes traine. Faithfully translated into English by E. A. * (London: Printed by John Wolfe, 1589) [page 40]:
Thou seekest to smite two blowes with one stone: For thou art not content to throwe at the king vnlesse the blowe light also vpon the king of Nauarre. Therefore when thou sayest that the king will giue vs the king of Nauarre for our gouernour, thou sayest, he is a wolfe to keepe the sheepe, and a foxe to looke to the hennes.
* The Contre-League and ansvvere to certaine letters [&c.] is a translation of the following French book : La Contre Ligue et Responce à certaines lettres envoyées à Messieurs de Renes par un ligueur se disant seigneur de la Valée du Maine et gentilhomme de la suite de feu Monsieur de Guyse ([s.l.], [s.n.], 1589).—This French book is unfortunately unavailable online.
The earliest figurative uses of the phrase a fox in the henhouse and variants that I have found are as follows, in chronological order:
1-: From an article about the address to the British public made by the newly-constituted Association for the Protection of British Industry and Capital, published in The North Wales Chronicle. And General Advertiser (Bangor, Caernarfonshire, Wales) of Tuesday 26th June 1849 [page 3, column 1]:
We see nothing that should prevent any one from becoming a member. It would be well for all concerned had the spirit of associationship been more largely embodied, for there would be no occasion at this time of day to bewail the ravages committed by free trade; agriculture, standing alone, having, in short, made little or no defence, though forewarned of the consequences of supineness. Let wolf assail the fold or fox enter the hen-house, there would be a rush to the rescue—would there not? One might have expected therefore from the agriculturists, at a time when the wolves of free trade were howling within ear-shot of their rural dwellings and menacing the Government, a bolder front, a courageous rather than a feeble assertion of rights. For this, the excuse is, we appointed keepers, and trusted in them; but the traitors gave us the slip! The keepers, not a whit more courageous than their masters, thought better to stop the mouths of the wolves, anyhow; so flinging about the fat of the land, in this manner saved their bacon. It is not the way to keep bacon long however, and the abandonment of an interest they mere pledged to uphold will be followed by a demand for compensation in one shape or another. Says the Farmer to the Fox, “you’ll pay for the goose your [sic] eating.” We trust they can well afford to do.
2-: From a letter to the Colonial Secretary, in which one Isaac Breaker complained about the City Commissioners and their Assessor on the subject of city rates, published in The Times (Adelaide, South Australia, Australia) of Saturday 25th May 1850 [page 8, column 2]:
Have the Commissioners no time for the discharge of the duties of their own office? […]
Only think, too, of sending their assessor to rectify his own errors! This is like sending the fox back into the hen-house to see that he had not taken more than he ought to do! What report could be expected of him, but that he had not, from any roost, taken a single fowl too many; and, if he had, in his haste, taken two or three lean ones, instead of two three fat ones close by, would he not be ashamed to confess the blunder?
3-: From an account of the public meeting of the Protestant inhabitants of Edinburgh and its vicinity, of all denominations, that was held on Thursday 27th March 1851, published in The Witness (Edinburgh, Midlothian, Scotland) of Saturday 29th March 1851 [page 3, column 5]:
The Rev. Jonathan Watson (Baptist) said […] that Popery did not exist as a purely spiritual system in Scotland before the Reformation, and that it bound in chains of ignorance the national mind […]. He said, Oh for an Oliver Cromwell at head quarters!—(great applause)—the tramp of whose foot on the floor of Whitehall would have turned to the right about those who were terror-stricken, and would have sent back the Cardinal to Rome with the message, “Tell your master that Victoria governs, and that while the house of Hanover sits on the English throne, no Prince of Rome shall ever establish the Papal hierarchy on British ground.” (Renewed cheering.) The reverend gentleman then said that the whole history of Popish encroachments reminded one of the fox in the hen-house, when Reynard, finding his prey roosting high over head, fell to whizzing rapidly round till the hens became dizzy, and, falling down, became his easy prey, The old fox of Rome has successfully performed before the University of Oxford—(laughter and applause)—and now that he has got into Downing Street and St. Stephen’s, if we cannot succeed in arresting his “cantrips,” to use a good old Scotch word, and driving him away, the issue need not be predicted.
4-: From a transcript of the speech that the U.S. politician Thomas Hart Benton (1782-1858) delivered at Hillsboro, Missouri, on Thursday 1st April 1852, published in the Jefferson Inquirer (Jefferson City, Missouri, USA) of Saturday 8th May 1852 [page 2, column 1]—reprinted from The St. Louis Union (St. Louis, Missouri, USA):
They gave a rule to go by in separating the deceivers from the deceived—separating the old nullification democrats from merely the misled democrats; disgusting the latter, and making them return to the body of the party in good faith, and from natural affection, while the old sinners would only return to it upon the principle that the FOX returns to the hen-house—to eat up the old hen, and all her chickens, and suck the eggs besides.