Police said the incident happened on Tuesday at a property in the Huntly area.
A 15-year-old boy and a 16-year-old boy have been charged with reckless conduct in connection with the incident.
No-one was injured and a report is being sent to the procurator fiscal, officers said.
Sgt Ian Moeller added: "I would like to take this opportunity to stress how deadly fireworks can be in the wrong hands and when let off in the wrong place and at the wrong time.
"Without being in complete control you have no idea how the situation will develop and what the outcome will be.
"What might be considered to be a prank could have deadly consequences."
Two teenage boys have been charged after a firework was posted through a letterbox in Aberdeenshire.