You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Dec 17, 2024. It is now read-only.
Hello,
everywhere in your security definer function, we can see:
execute 'REVOKE CREATE ON SCHEMA $my_schema FROM public' to tighten security or comment out the DO block to disable the check$$;
i'm not sure it is a good explaination, should we replace this sentence with
execute 'REVOKE CREATE ON SCHEMA public FROM PUBLIC' to tighten security or comment out the DO block to disable the check$$;
let's do an example
createdatabasemydb;
\c mydb
createschemamyschema;
then execute your fn used to check for unsecured schema
DO $SQL$
DECLARE
l_secure_schemas_from_search_path text;
BEGINSELECT string_agg(safe_sp, ', 'ORDER BY rank) INTO l_secure_schemas_from_search_path FROM (
SELECT quote_ident(nspname) AS safe_sp, rank
FROM unnest(regexp_split_to_array(current_setting('search_path'), ',')) WITH ORDINALITY AS csp(schema_name, rank)
JOIN pg_namespace n
ON quote_ident(n.nspname) = CASE WHEN schema_name ='"$user"' THEN quote_ident(user) ELSE trim(schema_name) END
WHERE NOT has_schema_privilege('public', n.oid, 'CREATE')
) x;
IF coalesce(l_secure_schemas_from_search_path, '') ='' THEN
RAISE NOTICE 'search_path = %', current_setting('search_path');
RAISE EXCEPTION $$get_stat_statements() SECURITY DEFINER helper will not be created as all schemas on search_path are unsecured where all users can create objects -
execute 'REVOKE CREATE ON SCHEMA $my_schema FROM public' to tighten security or comment out the DO block to disable the check$$;to tighten security or comment out the DO block to disable the check$$;
ELSE
RAISE NOTICE '%', format($$ALTER FUNCTION get_stat_statements() SET search_path TO %s$$, l_secure_schemas_from_search_path);
EXECUTE format($$ALTER FUNCTION get_stat_statements() SET search_path TO %s$$, l_secure_schemas_from_search_path);
END IF;
END;
$SQL$;
even if you
REVOKE CREATE ON SCHEMA myschema FROM public;
REVOKE CREATE ON SCHEMA myschema FROM PUBLIC;
you will face the warning. The only way to create the helpers fn is to execute
REVOKE CREATE ON SCHEMA public FROM PUBLIC
that's why i think the message
execute 'REVOKE CREATE ON SCHEMA $my_schema FROM public' to tighten security or comment out the DO block to disable the check$$;
Hello,
everywhere in your security definer function, we can see:
i'm not sure it is a good explaination, should we replace this sentence with
let's do an example
then execute your fn used to check for unsecured schema
even if you
you will face the warning. The only way to create the helpers fn is to execute
that's why i think the message
is not appropriate.
as describe here https://www.cybertec-postgresql.com/en/abusing-security-definer-functions/
why don't you set search_path at the beginning of the helpers functions ?
The text was updated successfully, but these errors were encountered: