rhel 7
format weakness #20

4

Weakness Breakdown


Definition:

A format string exploit occurs when the data of an input string is evaluated as a command by the program. This class of attacks is very similar to buffer overflows since an attacker could execute code, read the stack or cause new behaviors that compromise security. Learn more about format string attacks on OWASP attack index.

Warning code(s):

Potential format string problem.

File Name:

lasso-2.5.1/tests/perfs.c

Context:

The highlighted line of code below is the trigger point of this particular Red Hat Enterprise Linux 7 format weakness.

 	char *index = "5-saml2";
	GList *providers;
	LassoKey *key;
	LassoProvider *provider;
	gboolean use_shared_secret = FALSE;
	int opt = 0;

	while ((opt = getopt(argc, argv, "hn:s:")) != -1) {
		switch (opt) {
			case 'h':
				use_shared_secret = TRUE;
				break;
			case 'n':
				n = atoi(optarg);
				break;
			case 's':
				index = optarg;
				break;
		}
	}

	printf("Looping %d times, %susing metadata %s\n", n,
			use_shared_secret ? "with shared secret key, " : "", index);

	sprintf(sp_metadata, SP_METADATA, index);
	sprintf(sp_pkey, SP_PKEY, index);
	sprintf(idp_metadata, IDP_METADATA, index);
	sprintf(idp_pkey, IDP_PKEY, index);

	lasso_init();

	sp_server = lasso_server_new(
			sp_metadata,
			sp_pkey,
			NULL, /* Secret key to unlock private key */
			NULL);
	lasso_server_add_provider(
			sp_server,
			LASSO_PROVIDER_ROLE_IDP,
			idp_metadata,
			idp_pkey,
			NULL);
	if (use_shared_secret) {
		key = lasso_key_new_for_signature_from_memory("xxxxxxxxxxxxxxxx", 16,
				NULL, LASSO_SIGNATURE_METHOD_HMAC_SHA1, NULL);
		providers = g_hash_table_get_values(sp_server->providers);
		provider = LASSO_PROVIDER(providers->data);
		lasso_provider_set_server_signing_key(provider, key);
		lasso_provider_add_key(provider, key, FALSE);
		g_list_free(providers); 

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.