Challenge Description:
This challenge has no outgoing internet connection
what we got was a grafana instance with anonymous access and a postgresql datasource
i opened the instance and saw anonymous access was enabled
api datasources was open and it showed the postgresql datasource
then i opened the public dashboard and confirmed the datasource was in use
the dashboard json showed raw sql queries so api ds query could run sql
i used sql to read docker entrypoint init sql and found the reused password
SQL
CREATE ROLE postgres WITH LOGIN PASSWORD 'HelloWorld!!'
CREATEDB
CREATEROLE
INHERIT;
GRANT pg_read_server_files, pg_write_server_files TO postgres;
GRANT pg_monitor, pg_read_all_settings, pg_read_all_stats, pg_stat_scan_tables TO postgres;
GRANT pg_read_all_data, pg_write_all_data TO postgres;
the leaked password worked for grafana admin and i got in
after that i made a new datasource with user admin and got database admin access
copy from program gave command execution
i used ld preload to hook fopen fwrite and chmod
running flag bin revealed the flag
Hook Output
[hook] init
[hook] fopen(/var/lib/postgresql/18/docker/flag.txt,w)
[hook] fwrite size=1 nmemb=32 total=32 data=dalctf{h3ll0_y0ung_gr455h0pp3r}
[hook] chmod(/var/lib/postgresql/18/docker/flag.txt,666)
exit 0
Flag
dalctf{h3ll0_y0ung_gr455h0pp3r}