Hidden Messages in Emojis and Hacking the US Treasury
41–50 of 82 posts
Re: Hidden Messages in Emojis and Hacking the US Treasury
#42Earlier quoted context omitted.
The only reason BeyondTrust implemented that was it wasn't untrusted user commands . They sanitized the data, so it should have been fine. The unfortunate problem was that the sanitizer didn't sanitize. Systems are built on a set of expectations. Undermine the expectations and you undermine the system.
> They sanitized the data, so it should have been fine. This is a 101 rookie level approach to SQL or injection defense. It's dumb for exactly the same reason why this is dumb "SELECT * FROM foo WHERE bar=" + sanitize(userInput) The correct way to do something like this will always be parameterized input which looks something like this "SELECT * FROM foo WHERE bar=?" bindParameter(1, userInput); Why? Because that the…
Re: Hidden Messages in Emojis and Hacking the US Treasury
#43I learned about the breach a few days ago but I didn't know that you could "adopt" an emoji: https://aac.unicode.org/sponsors That's a neat tidbit.
Does "adopting an emoji" mean something other than "appearing on that page"? From the adoption page: Each adoption comes with a digital badge and certificate that you can proudly display.
Re: Hidden Messages in Emojis and Hacking the US Treasury
#44https://xkcd.com/3054/ (the scream cypher)
And halfway through implementing it. I realized that these combining characters will attach to any letter, and it would be easy to have crappy stegonography on top of your crappy ceaser cypher.
Probably nothing new, but I had fun.
D̊o̝ n̝o̊ť f̔o͞r̊g̝e͞t̍ t̊h̠e̗ milk
import string
def combine_list():
l = []
for c in range(0x0300, 0x0370):
if c != 0x340f: #non joiner mark
l.append(chr(c))
#print(str(c), 'A' + chr(c))
return l
class codebook_a():
def __init__(self):
self.cb = dict(zip(string.printable, combine_list()))
self.cb[''] = ''
self.d = {}
for c in self.cb:
self.d[self.cb[c]] = c
def encode(self, message, fake):
if len(message) > len(fake):
raise ValueError('fake must be longer than message')
ml = list(message)
fl = list(fake)
encode = []
while fl:
c = fl.pop(0)
if c != ' ':
if ml:
m = ml.pop(0)
else:
m = ''
encode.append(c + self.cb[m])
else:
encode.append(c)
return ''.join(encode)
def decode(self, message):
plain = []
for c in message:
p = self.d.get(c)
if p is not None:
plain.append(p)
return ''.join(plain)
def cli(args):
cb = codebook_a()
#check for coded text
if len(args) == 0:
print('message fake : two args')
print('a message with no combining charactors(dicritics) will be coded onto fake')
print('with combining charactors will extract the real message')
return 1
m = args[0]
for c in m:
if cb.d.get(c):
print('decode')
print(cb.decode(m))
return 0
print('encode')
print(cb.encode(m, args[1]))
if __name__ == '__main__':
import sys
cli(sys.argv[1:])Re: Hidden Messages in Emojis and Hacking the US Treasury
#45> Now, all of this might have been fine had Beyond Trust not written a feature which allowed users to directly, programmatically interact with psql (the postgres command line interface). That's the buried lede. Yes, there was a vulnerability in psql... but that's so much less a problem than the huge gaping hole of allowing users to directly interact with psql. No DB can be safe if you are turning untrusted user comma…
The author discovered quite a few... well lets just call them policy errors in postgres, but had a hard time filing bug reports, mainly because the response was usually an incredulous "why on earth would you even do that in the first place?.
But the author has fun with this, There is a trophy in the game that you can only get by putting your name in the trophy table.
Re: Hidden Messages in Emojis and Hacking the US Treasury
#46I learned about the breach a few days ago but I didn't know that you could "adopt" an emoji: https://aac.unicode.org/sponsors That's a neat tidbit.
Does "adopting an emoji" mean something other than "appearing on that page"? From the adoption page: Each adoption comes with a digital badge and certificate that you can proudly display.
Re: Hidden Messages in Emojis and Hacking the US Treasury
#47Earlier quoted context omitted.
The only reason BeyondTrust implemented that was it wasn't untrusted user commands . They sanitized the data, so it should have been fine. The unfortunate problem was that the sanitizer didn't sanitize. Systems are built on a set of expectations. Undermine the expectations and you undermine the system.
> They sanitized the data, so it should have been fine. This is a 101 rookie level approach to SQL or injection defense. It's dumb for exactly the same reason why this is dumb "SELECT * FROM foo WHERE bar=" + sanitize(userInput) The correct way to do something like this will always be parameterized input which looks something like this "SELECT * FROM foo WHERE bar=?" bindParameter(1, userInput); Why? Because that the…
Btw, even using psql directly allows binding parameters https://www.postgresql.org/docs/current/app-psql.html
Re: Hidden Messages in Emojis and Hacking the US Treasury
#48Earlier quoted context omitted.
The only reason BeyondTrust implemented that was it wasn't untrusted user commands . They sanitized the data, so it should have been fine. The unfortunate problem was that the sanitizer didn't sanitize. Systems are built on a set of expectations. Undermine the expectations and you undermine the system.
> They sanitized the data, so it should have been fine. This is a 101 rookie level approach to SQL or injection defense. It's dumb for exactly the same reason why this is dumb "SELECT * FROM foo WHERE bar=" + sanitize(userInput) The correct way to do something like this will always be parameterized input which looks something like this "SELECT * FROM foo WHERE bar=?" bindParameter(1, userInput); Why? Because that the…
Re: Hidden Messages in Emojis and Hacking the US Treasury
#49So many questions: - why a no side-effects function on a database can be used to get lateral access to the whole database instance - why do you need to validate strings on the database itself and not on the client anyway, heck why are there no type safe way of doing it - why would you want to execute shell commands from the database itself - Even if there's a real use case for executing commands like that why is it e…
They mentioned PAM module so maybe the sql injection just allowed bypassing the authorization of a system that was using the PAM module. Like it’s in the realm of possibility that a PAM module that wanted to validate a user against credentials stored in a pg database might shell out to the psql command to do this. Though, the whole thing is very questionable.
Re: Hidden Messages in Emojis and Hacking the US Treasury
#50Earlier quoted context omitted.
The only reason BeyondTrust implemented that was it wasn't untrusted user commands . They sanitized the data, so it should have been fine. The unfortunate problem was that the sanitizer didn't sanitize. Systems are built on a set of expectations. Undermine the expectations and you undermine the system.
> They sanitized the data, so it should have been fine. This is a 101 rookie level approach to SQL or injection defense. It's dumb for exactly the same reason why this is dumb "SELECT * FROM foo WHERE bar=" + sanitize(userInput) The correct way to do something like this will always be parameterized input which looks something like this "SELECT * FROM foo WHERE bar=?" bindParameter(1, userInput); Why? Because that the…
> Why? Because [] the postgres protocol splits out the command and the data for the command in a way that can't be injected.
I'm not sure I'm comfortable with this. You can create a prepared statement and then pass user input to it as parameters, sure. https://www.postgresql.org/docs/17/sql-prepare.html
But who says that means your statement can't be injected? It would have to be true that the handling for EXECUTE statements is bug-free. Maybe it is bug-free. Or maybe it isn't. Maybe I can figure out just the right username to cause your prepared statement to have some undesirable side effects.
That wouldn't be SQL injection in the sense of putting hostile values into an SQL query in order to form a different SQL query, but it would be SQL injection in the sense of putting hostile values into an SQL query in order to accomplish nefarious goals via the database. The only real qualm I'd have about calling it "SQL injection" is that it wouldn't be portable across different database implementations; it would be more accurately described as "PostgreSQL injection".
If we feel entitled to assume that PostgreSQL's provided functionality to interpret strings that are provided to EXECUTE statements has no bugs, why aren't we also entitled to assume that PostgreSQL's provided functionality to interpret strings that are provided to the string escaper has no bugs? I don't really see the conceptual difference.