Is someone who has not yet been baptized allowed to go to confession?
Can. 842 §1. A person who has not received baptism cannot be admitted validly to the other sacraments.
Can. 959 In the sacrament of penance the faithful who confess their sins to a legitimate minister, are sorry for them, and intend to reform themselves obtain from God through the absolution imparted by the same minister forgiveness for the sins they have committed after baptism and, at the same, time are reconciled with the Church which they have wounded by sinning (emphasis added).
The Baltimore Catechism:
Q. 637. Can a person ever receive any of the other sacraments without first receiving baptism?
A. A person can never receive any of the other sacraments without first receiving baptism, because baptism makes us members of Christ’s Church, and unless we are members of his Church we cannot receive his sacraments.
Baptism is the first sacrament of the Christian life. It brings forgiveness for all sins received prior to the baptism and imparts new life to the recipient. Confession is the sacrament for forgiveness of sins committed after baptism and restores the recipient to the state of grace received at baptism.