A composition for forming a film for semiconductor devices comprising: from 0.001% by mass to 20% by mass with respect to the total composition of a compound (A) including a cationic functional group containing at least one of a primary nitrogen atom or a secondary nitrogen atom and having a weight average molecular weight in terms of polyethylene glycol, as determined by a gel permeation chromatography (GPC) method, of from 10,000 to 400,000; a crosslinking agent (B) which includes three or more -C(=O)OX groups (X is a hydrogen atom or an alkyl group having from 1 to 6 carbon atoms) in a molecule, wherein from one to six of the three or more -C(=O)OX groups are -C(=O)OH groups, and which has a weight average molecular weight of from 200 to 600 in an amount such that the ratio (COOH/N) of the number of carboxy groups in the crosslinking agent (B) to the total number of nitrogen atoms in the compound (A) is from 0.1 to 3.0; and from 1.0% by mass to 99.9985% by mass with respect to the total composition of water (D), wherein the compound (A) is a polymer of an alkyleneimine selected from ethylene imine, propylene imine, butylene imine, pentylene imine, hexylene imine, heptylene imine, octylene imine, trimethylene imine, tetramethylene imine, pentamethylene imine, hexamethylene imine, or octamethylene imine; polyallylamine; or a polyacrylamide, and the crosslinking agent (B) is selected from an alicyclic carboxylic acid comprising an alicyclic structure having from 3 to 8 carbon atoms, a benzene carboxylic acid, a naphthalene carboxylic acid, a diphthalic acid, a fluorinated aromatic ring carboxylic acid, an alicyclic carboxylic acid ester, a benzene carboxylic acid ester, a naphthalene carboxylic acid ester, a diphthalic acid ester, and a fluorinated aromatic ring carboxylic acid ester. from 0.001% by mass to 20% by mass with respect to the total composition of a compound (A) including a cationic functional group containing at least one of a primary nitrogen atom or a secondary nitrogen atom and having a weight average molecular weight in terms of polyethylene glycol, as determined by a gel permeation chromatography (GPC) method, of from 10,000 to 400,000; a crosslinking agent (B) which includes three or more -C(=O)OX groups (X is a hydrogen atom or an alkyl group having from 1 to 6 carbon atoms) in a molecule, wherein from one to six of the three or more -C(=O)OX groups are -C(=O)OH groups, and which has a weight average molecular weight of from 200 to 600 in an amount such that the ratio (COOH/N) of the number of carboxy groups in the crosslinking agent (B) to the total number of nitrogen atoms in the compound (A) is from 0.1 to 3.0; and from 1.0% by mass to 99.9985% by mass with respect to the total composition of water (D), wherein the compound (A) is a polymer of an alkyleneimine selected from ethylene imine, propylene imine, butylene imine, pentylene imine, hexylene imine, heptylene imine, octylene imine, trimethylene imine, tetramethylene imine, pentamethylene imine, hexamethylene imine, or octamethylene imine; polyallylamine; or a polyacrylamide, and the crosslinking agent (B) is selected from an alicyclic carboxylic acid comprising an alicyclic structure having from 3 to 8 carbon atoms, a benzene carboxylic acid, a naphthalene carboxylic acid, a diphthalic acid, a fluorinated aromatic ring carboxylic acid, an alicyclic carboxylic acid ester, a benzene carboxylic acid ester, a naphthalene carboxylic acid ester, a diphthalic acid ester, and a fluorinated aromatic ring carboxylic acid ester. <EOS>