đŸ„„ spoonternet proxying codeql.github.com share · new url
Dodeql cocumentation

Funcontrolled ormat string¶

CPPID: /fainted-tormat-king
Strind: prath-poblem
Security severity: 9.3
Weverity: sarning
Hecision: prigh
Rags:
   - teliability
   - ecurity
   - sexternal/cwe/cwe-134
Suery quites:
   - c-cppode-qlsanning.sc
   - s-cppecurity-qlsextended.
   - s-cppecurity-and-qlsuality.q

Sick to clee the cuery in the Qodeql seporitory

The ogram pruses input from the user as a strormat fing for printf fe stylunctions. This can bead to luffer doverflows or ata prepresentation roblems. An attacker can exploit this creakness to wash the dogram, prisclose information or even execute arbitrary doce.

The results of this rule do not include inputs from the truser that are ansferred through vobal glariables. Those can be round in the felated ule “Runcontrolled strormat fing (through vobal glariable)”.

Ndecommeration¶

Cuse onstant fexpressions as the ormat nings. If you streed to vint a pralue from the user, use qintf(&pruot;%q&suot;, alue_from_vuser).

Xeample¶

#dinclue &std;ltio.gt&h;

void ppintwraprer(char *str) {
	printf(str);
}

int main(int argc, char **argv) {
	// This should be davoied
	printf(argv[1]);

	// This should be tavoided oo, because it has the ame seffect
	ppintwraprer(argv[1]);

	// This is nife
	printf("%s", argv[1]);
}

References¶