- Notifications
You must be signed in to change notification settings - Fork86
CVE-2018-1058 fixes#415
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
4 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
6 changes: 3 additions & 3 deletionssrc/backup.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletionssrc/checkdb.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletionssrc/ptrack.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletionsrc/util.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
30 changes: 29 additions & 1 deletionsrc/utils/pgut.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
143 changes: 143 additions & 0 deletionstests/CVE_2018_1058.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
import os | ||
import unittest | ||
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException | ||
module_name = 'CVE-2018-1058' | ||
class CVE_2018_1058(ProbackupTest, unittest.TestCase): | ||
# @unittest.skip("skip") | ||
def test_basic_default_search_path(self): | ||
"""""" | ||
fname = self.id().split('.')[3] | ||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup') | ||
node = self.make_simple_node( | ||
base_dir=os.path.join(module_name, fname, 'node'), | ||
set_replication=True) | ||
self.init_pb(backup_dir) | ||
self.add_instance(backup_dir, 'node', node) | ||
node.slow_start() | ||
node.safe_psql( | ||
'postgres', | ||
"CREATE FUNCTION public.pgpro_edition() " | ||
"RETURNS text " | ||
"AS $$ " | ||
"BEGIN " | ||
" RAISE 'pg_probackup vulnerable!'; " | ||
"END " | ||
"$$ LANGUAGE plpgsql") | ||
self.backup_node(backup_dir, 'node', node, backup_type='full', options=['--stream']) | ||
# Clean after yourself | ||
self.del_test_dir(module_name, fname) | ||
# @unittest.skip("skip") | ||
def test_basic_backup_modified_search_path(self): | ||
"""""" | ||
fname = self.id().split('.')[3] | ||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup') | ||
node = self.make_simple_node( | ||
base_dir=os.path.join(module_name, fname, 'node'), | ||
set_replication=True) | ||
self.set_auto_conf(node, options={'search_path': 'public,pg_catalog'}) | ||
self.init_pb(backup_dir) | ||
self.add_instance(backup_dir, 'node', node) | ||
node.slow_start() | ||
node.safe_psql( | ||
'postgres', | ||
"CREATE FUNCTION public.pg_control_checkpoint(OUT timeline_id integer, OUT dummy integer) " | ||
"RETURNS record " | ||
"AS $$ " | ||
"BEGIN " | ||
" RAISE '% vulnerable!', 'pg_probackup'; " | ||
"END " | ||
"$$ LANGUAGE plpgsql") | ||
node.safe_psql( | ||
'postgres', | ||
"CREATE FUNCTION public.pg_proc(OUT proname name, OUT dummy integer) " | ||
"RETURNS record " | ||
"AS $$ " | ||
"BEGIN " | ||
" RAISE '% vulnerable!', 'pg_probackup'; " | ||
"END " | ||
"$$ LANGUAGE plpgsql; " | ||
"CREATE VIEW public.pg_proc AS SELECT proname FROM public.pg_proc()") | ||
self.backup_node(backup_dir, 'node', node, backup_type='full', options=['--stream']) | ||
log_file = os.path.join(node.logs_dir, 'postgresql.log') | ||
with open(log_file, 'r') as f: | ||
log_content = f.read() | ||
self.assertFalse( | ||
'pg_probackup vulnerable!' in log_content) | ||
# Clean after yourself | ||
self.del_test_dir(module_name, fname) | ||
# @unittest.skip("skip") | ||
def test_basic_checkdb_modified_search_path(self): | ||
"""""" | ||
fname = self.id().split('.')[3] | ||
node = self.make_simple_node( | ||
base_dir=os.path.join(module_name, fname, 'node'), | ||
initdb_params=['--data-checksums']) | ||
self.set_auto_conf(node, options={'search_path': 'public,pg_catalog'}) | ||
node.slow_start() | ||
node.safe_psql( | ||
'postgres', | ||
"CREATE FUNCTION public.pg_database(OUT datname name, OUT oid oid, OUT dattablespace oid) " | ||
"RETURNS record " | ||
"AS $$ " | ||
"BEGIN " | ||
" RAISE 'pg_probackup vulnerable!'; " | ||
"END " | ||
"$$ LANGUAGE plpgsql; " | ||
"CREATE VIEW public.pg_database AS SELECT * FROM public.pg_database()") | ||
node.safe_psql( | ||
'postgres', | ||
"CREATE FUNCTION public.pg_extension(OUT extname name, OUT extnamespace oid, OUT extversion text) " | ||
"RETURNS record " | ||
"AS $$ " | ||
"BEGIN " | ||
" RAISE 'pg_probackup vulnerable!'; " | ||
"END " | ||
"$$ LANGUAGE plpgsql; " | ||
"CREATE FUNCTION public.pg_namespace(OUT oid oid, OUT nspname name) " | ||
"RETURNS record " | ||
"AS $$ " | ||
"BEGIN " | ||
" RAISE 'pg_probackup vulnerable!'; " | ||
"END " | ||
"$$ LANGUAGE plpgsql; " | ||
"CREATE VIEW public.pg_extension AS SELECT * FROM public.pg_extension();" | ||
"CREATE VIEW public.pg_namespace AS SELECT * FROM public.pg_namespace();" | ||
) | ||
try: | ||
self.checkdb_node( | ||
options=[ | ||
'--amcheck', | ||
'--skip-block-validation', | ||
'-d', 'postgres', '-p', str(node.port)]) | ||
self.assertEqual( | ||
1, 0, | ||
"Expecting Error because amcheck{,_next} not installed\n" | ||
" Output: {0} \n CMD: {1}".format( | ||
repr(self.output), self.cmd)) | ||
except ProbackupException as e: | ||
self.assertIn( | ||
"WARNING: Extension 'amcheck' or 'amcheck_next' are not installed in database postgres", | ||
e.message, | ||
"\n Unexpected Error Message: {0}\n CMD: {1}".format( | ||
repr(e.message), self.cmd)) | ||
# Clean after yourself | ||
self.del_test_dir(module_name, fname) |
4 changes: 3 additions & 1 deletiontests/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.