Kristen Paquette, 27, has been charged with reckless endangerment to a child and assault and battery on a child.
The 27-year-old mother was held on $10,000 bail after being arraigned on Friday in Lowell District Court, Massachusetts.
Police said the child was naked and covered in urine and faeces when, acting on a tip, officers went to the Lowell home on Thursday. They estimated the temperature inside the attic at over 38 degrees celsius.
The door to the room was locked, and the only window inside was nailed shut, said prosecutor Dan Harren. Feces-covered child-size fingerprints were on the wall, he said.
Outside the attic was a similarly filthy mattress, surrounded by hundreds of flies, Harren said.
Investigators said Paquette forced the boy into the attic, and that it "was not an isolated incident". Other children in the apartment told police: "Mommy does this when she gets angry," Harren said.
"When asked how long the child had been upstairs, the defendant admitted in a nonchalant manner, 'about an hour'," Harren said.
The woman's father, Alfred Paquette, said police were misrepresenting the situation. He said his daughter is a single mother who is overwhelmed by her four children - a daughter and three sons.
Alfred Paquette said the first floor of the home is clean, and the four children seem happy and never appeared abused.
Paquette's defence lawyer, Kathleen Moore, told Judge Neil Walker: "It is clear this is a woman who needed help and didn't know how to ask for it and didn't ask for it."
Two of the other children, ages six and nine, were placed in state custody, as was a third child who wasn't home at the time. Alfred Paquette said he was with the child at Fenway Park, watching the Boston Red Sox defeat the Oakland Athletics.