How to use Unicode encoding for evading XSS filter?

Use the package AntiXssEncoder of Nuget with:

Install-Package AntiXSS -Version 4.3.0

This Class has diferents encoders for each case in that this values is reflected, for example css, JavaScript, HTML, and URL; Use this methods depend on your case, for example:

In CSS use:
CssEncode("data")
In Javascript use:
JavaScriptStringEncode("data")

This solucion allow validate of major types for bypass the encoding, assurance to \u0027, %27 and much diferents options.

Other way is first normalize and encode the data, this allow validate for example, %u0027, \x00,%00 and change the value to specific language for evading bypass a validation.

https://msdn.microsoft.com/en-us/library/system.web.security.antixss.antixssencoder(v=vs.110).aspx
https://msdn.microsoft.com/es-es/library/ebza6ck1(v=vs.110).aspx

I hope that I help you.


Stations not deauthenticating when using Aircrack-ng

I think your issue is still Protected Management Frames which appear mandatory in 802.11ac. See 802.11w protected management frames - Wi-Fi

  but this AP does not support PMF

Specifically:
"The IEEE 802.11w amendment added this functionality to the 802.11 standard and since July 1st 2014, the Wi-Fi Alliance (WFA) made the support of Protected Management Frames (PMF) mandatory to pass 802.11ac or Passpoint aka HotSpot2.0 R2 interoperability certification. So we will see a much greater adoption of this feature in the near future."

Source

I am curious how you know it doesn't support it, is that due to it not referencing it in the admin interface or from the frames it's sending out? You should be able to confirm this by checking the packets coming from the AP and looking for the presence of the bit identifying PMF support.

Also slight technicality but the attack used to work as the wireless clients believed they had been disassociated by the AP, not the other way around.

TL;DR: De-authentication frames are now signed using the wireless key because of something called "PMF" which is mandatory to pass 802.11ac certification. Your AP probably supports PMF without you realising.


will everything just be a blur

No. SSL/TLS does not make use of "cover traffic". With cover traffic, the line is kept constantly busy in both directions. Regardless of whether any actual payload is actually being transferred.

With SSL/TLS when nothing happens, the line is idle.

This allows for some meta-data analysis. The flows to/from and their rough size will be visible to eavesdroppers.


Time zone settings and leakage of location

Yes, it's possible to retrieve information about the local system time and timezone from JavaScript. A script might fetch that and post it back to a server via Ajax or other measures. Your browser may also provide headers that include timestamps, so detection might be possible even when JavaScript is disabled.

It's impossible to iterate through all the potential ways that timezones and timestamps can be leaked, but here's a quick list:

JavaScript
Flash, Java, etc. plugins.
HTTP headers
Cache detection tricks
Cookie tricks (e.g. setting a cookie to expire at a fixed date, then see when it expires)

All in all, though, I wouldn't be too worried. Timezones are a very weak identifier of location. I'd be much more worried about IP-based geolocation, ping triangulation, direct access to location services, etc.


Can "cat-ing" a file be a potential security risk?

Yes, it's a potential risk, see CVE-2003-0063, or CVE-2008-2383 or CVE-2010-2713, or CVE-2012-3515 or OSVDB 3881, or CVE-2003-0020 or any of the similar ones listed here... Some more in comments below also.

Update it's not just a potential risk, it's a real risk.
rxvt-unicode (versions 2.7—9.19,  patched in 9.20) allows read/write access to X window properties, this can enable user-assisted execution of arbitrary commands, this issue has been assigned CVE-2014-3121, more details here https://bugzilla.redhat.com/show_bug.cgi?id=1093287 .

More recently (October 2019) iTerm2 versions up to v3.3.5 were found to have the same class of problem: display of malicious content can enable the integrated tmux and permit command execution, see CVE-2019-9535.

This topic also has good coverage here: https://unix.stackexchange.com/questions/73713/how-safe-is-it-to-cat-an-arbitrary-file and a thorough analysis of the underlying problem from Gilles here: https://unix.stackexchange.com/questions/15101/how-to-avoid-escape-sequence-attacks-in-terminals .

Explanation

What you are observing is a side-effect of how certain escape sequences behave: some of them stuff characters (usually also containing escape sequences) directly into the terminal input buffer. All in the name of backward compatibility, of course. The standard xterm escapes which are described using  the term "Report <something>" do this. This behaviour permits programs to query/set terminal (or other) properties "in band" rather than via ioctls or some other API.

As if that wasn't bad enough, some such sequences can contain a newline, which means that whatever is reading from the terminal (your shell) will see what appears to be a complete user command.

Here's a neat way to use this, with bash's read to print an escape (as a prompt) then immediately read and split the reply into variables:

IFS=';' read -sdt -p $'\e[18t' csi8 rows cols
echo rows=$rows cols=$cols

These sequences can vary by terminal, but for rxvt and derived, the graphics query escape includes a newline (example using bash and $'' strings, see doc/rxvtRef.txt in the source)` :

$ echo $'\eGQ'
$ 0
bash: 0: command not found

This escape sends \033G0\n into the terminal input buffer (or digit 1 instead of 0 if you have a graphics-capable rxvt).

So, combine this escape with other sequences which behave similarly:

echo $'\x05' $'\e[>c' $'\e[6n' $'\e[x' $'\eGQ'

for me this causes 11 attempts to run various commands: 1, 2c82, 20710 (my rxvt version string), 0c5, 3R (5 and 3 were the cursor coords), 112 and 0x0.

Exploitable?

With rxvt and most recent terminal emulators you should "only" be able to create a limited set of mostly numeric sequences. In old terminal emulators it was possible (some CVEs listed above) to access the clipboard, the window icon and titlebar text to construct more malicious strings for invocation (one current slight exception is if you set the answerbackString X resource string, but that cannot be directly set using this method). The flaw then is allowing arbitrary read and write access to  something that passes for state or storage within escape sequences that stuff data into the input buffer.

rxvt requires compile time changes to activate, but urxvt helpfully has an -insecure command line option that enables some of the more exciting features:

$ echo $'\e]2;;uptime;\x07' $'\e[21;;t' $'\eGQ'
bash: l: command not found
17:59:41 up 1448 days,  4:13, 16 users,  load average: 0.49, 0.52, 0.48
bash: 0: command not found

The three sequences are:

\e]2;...\x07 set window title;
\e[21;;t query window title, place in input buffer;
\eGQ query graphics capability, which adds \n to input buffer.

Again, depending on terminal, other features such as font size, colors, terminal size, character set, alternate screen buffers and more may be accessible though escapes. Unintended modification of those is at least an inconvenience, if not an outright security problem. Current versions of xterm restrict potentially problematic features via "Allow*" resources.

CVE-2014-3121

Prior to v9.20, urxvt did not also guard read and write access to X properties (mostly used by window managers). Write read access (or more precisely, access to sequences which echo potentially arbitrary strings) now requires the -insecure option.

$ echo $'\e]3;xyzzy=uptime;date +%s;\x07'
$ xprop -id $WINDOWID xyzzy
xyzzy(UTF8_STRING) = 0x75, 0x70, 0x74, 0x69, 0x6d, 0x65, 0x3b, 0x64, 0x61, 0x74, \
0x65, 0x20, 0x2b, 0x25, 0x73, 0x3b

This can be trivially used to stuff arbitrary strings into the terminal input buffer. When the escape sequence to query a property is invoked (along with helpful \eGQ which adds a newline):

 $ echo $'\e]3;?xyzzy\x07' $'\eGQ'
 $ 3;uptime;date +%s;0
 bash: 3: command not found
 17:23:56 up 1474 days,  6:47, 14 users,  load average: 1.02, 1.20, 1.17
 1400603036
 bash: 0: command not found

Multiple commands, preserving whitespace and shell metacharacters.
This can be exploited in a variety of ways, starting with cat-ing an untrusted binary of course, further ideas in H.D. Moore's short paper (2003).

Followup

For the escape sequence you ask about: 1;112;112;1;0x1;2
This is: Request Terminal Parameters (DECREQTPARM) and Send Device Attributes :

$ echo $'\e[x' $'\e[0c'
;1;1;112;112;1;0x1;2c

The second one (\e[0c) is the same as ^E (using rxvt). There are some escape sequences in there too. the full sequence written for each is, respectively:

\e[1;1;1;112;112;1;0x
\e[?1;2c


How can I keep usernames out of /etc/passwd on LINUX

You could mitigate this by using an external server (perhaps LDAP, Samba, NIS, ..) for user authentication, and either using a network filesystem (NFS, Samba, ..) for home directories, and/or making those based on UID rather than username.

If you decide to implement this, double-check the network authentication doesn't stuff entries into the password file - IIRC, some systems do this.

Although usernames aren't often seen as a risk, it's 50% of the information needed in a user+password/key authentication mechanism - and it's why a well behaved login mechamism will say 'bad username or password' and not 'bad password'.

Another consideration is that in some circumstances, a username maps easily to an email address, so can be used by an attacker to harvest useful data.

A more paranoid consideration is that on a multi-user solution, an authorised user who wants to hack would probably want to work under someone else's login.


Who said the server has to trust you? For many HTTPS sites, a server does the same thing for everyone; Google is happy to do a search for anyone, and nothing it sends you is necessarily even a little bit sensitive from their point of view. If Google doesn't care who you are, there is literally no reason to do client authentication.

If client authentication is desired, you still don't need to do so through TLS. Once you have a secure channel to another party, you can send info along that channel, so once the server has authenticated the client can just authenticate by sending a password. That doesn't work for the server because there are typically many clients, all of whom would need to know the password, and so could impersonate the server to another client. In contrast, it's not as big a problem if the server can impersonate a client, because servers tend to be more trusted than clients (they'll take anyone as a client, the reverse is not true). If the client sends a password, the server must have already authenticated, so that's why that must happen in TLS, while client auth doesn't have to happen then.

Lastly, since passwords do work OK for client auth and are easier for users to deal with, most sites use them. TLS client certs from CAs have little point in most cases anyways; if pseudonymity is fine you can just have people directly upload a client cert of their choice, if it isn't you normally have a more authoritative issuer than just any commercial CA (i.e. have one trusted issuer, which is often just yourself)


How would you totally isolate a laptop from any network?

Put it in a locked room in the basement, remove the hardware that it could use to attach to a network (cat-5 cable, wifi antenna, use a UPS that isolates from mains). Now you have to limit the users ability to attach to some network through the exposed UI, I'd suggest a guard in a separate users room as shown in my previous answer here.


Deduplication works on detection of identical files or blocks of data. Such duplicates occur only with negligible probability in random data, and properly encrypted data ought to be indistinguishable from randomness. Encryption is there to ensure confidentiality and this includes, in particular, hiding from any eavesdropper whether two source data files are identical or not.

In that sense, deduplication can work on encrypted files only if the encryption model is weakened. This is not a light decision: in the case of your database, showing which "blocks" have changed and which have not can be quite revealing on what you did with your database in the meantime. The generic term is traffic analysis. The Wikipedia page lists several famous military cases; traffic analysis is also very good at predicting business tactics of competitors (e.g. noticing in advance preparations for release of new major products).

Assuming that you want to do block-level deduplication, despite the possible leaks alluded to above, there are good ways and bad ways to do it. First you need to split the input data into block-sized chunks, actually a bit smaller because of the need for an extra per-block header (for IV and a MAC). Each block will be encrypted separately. Now the tricky part is that for deduplication to work, the same block data must be reencrypted identically if it did not change between invocations -- so it must reuse the IV. Reusing IV value is a sin; it is deadly when using modes like CTR and in particular its modern derivatives GCM and EAX. The solution here is an IV computed with a one-way function from the block offset in the file, and its contents; the one-way function should be "random looking", and be keyed, because otherwise attackers could try exhaustive search on the data itself, matching with the block IV.

The following scheme should be safe (within the weakened model) but this would require some careful analysis:

There are two keys K1 and K2 (possibly derived from a single master key with a Key Derivation Function.
For block number i, with data d, compute IV = HMAC(K1, i || d) (the IV is the result of HMAC/SHA-256 over the concatenation of i and the data d, using K1 as key -- truncate the IV to its first 128 bits).
Encrypt d with AES, using the IV from previous step and key K2, in CBC mode.
Put the IV and the encryption result together in a block-size chunk.

This uses CBC and MAC-and-encrypt, which is "not ideal" as far as cryptography is concerned, but hey, weakened model. You get what you ask for.

Edit: Important note: though some HMAC is being used here, this does not guarantee integrity of the block data. You may use the IV for decryption and then recompute the IV and see if it matches the one in the file; this will prevent generic alterations, but an active attacker could still replace a block with an older version of this same block. If you need some integrity check on your backups, do the following: in addition to any encryption and MAC described above, compute a MAC or a signature on the complete file and verify that before using the backup (if you are restoring a backup, then I assume that you will read it completely anyway, so you could have the MAC or signature verification "for free").


How can two-man control be implemented efficiently?

The key is to only implement two-man control for operations that really need it.

Routine tasks

Routine tasks, like deploying an application release, or applying security patches can be scripted. One sys-admin can create the script, but it cannot be run until a second sys-admin has reviewed and approved it. Common tasks like restarting the application server, or deploying the latest application release, can have a pre-approved script that is used repeatedly. Non-standard tasks will need a bespoke script.

To do this, there's a need for some kind of workflow management system. You may be able to use a ticketing system like Trac, build a bespoke system on something like JIRA, and configuration management tools like Puppet may have features that would help. The two sys-admins do NOT need to be physically local; they can work remotely.

The systems should be designed so that as much routine maintenance is automated as possible - scheduled log rotation, etc.

Diagnostics

Sys-admins can have read-only access to logs without two-man control, provided the logs mask sensitive information. They can also have a low-privilege account to view status pages, and run commands like top or ps. This allows a single sys-admin to diagnose issues - and they can work remotely. They may be able to do remediation by submitting a script as a routine task. However, in some cases that won't be possible, so there is a need for emergency access.

Emergency access

Sometimes there is a serious issue and you just need to SSH in as root. To maintain two-man control you need two people at this point. In practice, they need to be physically next to each other. A simple way to implement access control is to have an account for each pairing, where each sys-admin knows half the password. You could create a smarter system with a custom PAM module, perhaps even requiring a separate smart card from both sys-admins.

Once logged in, it is down to the sys-admins to maintain two-man control. They must inspect each others commands before issuing, and lock the terminal if one of them needs to step out.

The aim should be that emergency access is rarely needed.

Development environments

It is only necessary to use two-man control for the live environment. A lone sys-admin can have full access to a development environment - provided that live data is not present. They can try out a task in the development environment, perform some testing, iron out the bugs. Only when they have got a working script do they submit it to another sys-admin for approval.

Conclusion

If all this is done, I believe you can implement strong two-man control with about 25% overhead. Making it a success relies on various things (like automated maintenance) that are good practice anyway. If a system is so sensitive as to need two-man control, it is a good idea to get all the basics right as well!

I have never seen this implemented in a commercial or government environment. The closest I have seen was an online banking platform where most sys-admins did not routinely have root access. To performs a task, this would first be planned in detail, then approved on the change control system. To implement the change the sys-admin then got root access for a limited period. Also, there were a small number of senior sys-admins who had permanent root access, in case of emergencies. This arrangement is much better than I typically see - although it falls short of full two-man control.


Is Debian 9.5 stretch vulnerable to CVE-2018-17182?

Yes. All mainline kernels from 3.15-rc8 commit  6b4ebc3a9078c5b7b8c4cf495a0b1d2d0e0bfe7a, up to the patch in 4.19-rc3 commit 7a9cdebdcc17e426fb5287e4a82db1dfe86339b2 are affected, and the Debian team has not patched it downstream for the version you are using.


Why recommend "letters, numbers, and special characters" in a User ID?

User ID are not nominally secret values; that's why we call them "user ID" and not "passwords", and why graphical interfaces for entering them don't hide the characters". However, creative designers sometimes imagine that user ID are some kind of secret, which leads to situations like what you witness: a site that tries to enforce on the user ID some "complexity rules" normally applied to passwords.

In practice, user ID chosen by users are not very secret, because:

Interfaces and protocols may leak user ID in various places.
Users don't consider them secret and thus will not try to make them unguessable.
Even when users try to make things hard to guess (passwords), they usually fail.

However, lack of rationality has never prevented any enthusiastic developer from adding features.

Arguably, insistence on including "special characters" in strings is not proven to really make these strings harder to guess. Such so-called complexity rules are meant to force users out of their comfort zone (it works: users are much less happy), under the rather specious assumption that an irate or depressed user will somehow choose passwords which are harder to guess.


Are password managers more secure than a slightly different password for each website?

Yes, decent password managers are more secure than using any password pattern.

You have a password manager, and it has created you random passwords:

6AKQ3)mcV!xX3b8-ZgncCe%tdn!&.@3X
a6/4TFaWKrzTHQyT2Df#;/*+QA$zH2tJ
9y__&%7jP4UcuG(9f7X6z44C#64bF:m&
9W649r788_8AU=9272zuGH"=C?2&C66j
nT29HMc$y'H)ww2#D/2x(2sBU#WG23us

Versus you have a pattern for your passwords:

correctbatteryhorsestaplegithub
correctbatteryhorsestaplestackexchange
correctbatteryhorsestaplegooogle
correctbatteryhorsestaplesomesite
correctbatteryhorsestapleapple

The site #4 has a bad practice of saving passwords in plain text, and their password database leaks. Now, from the latter it's possible to assume that this is a password pattern you use and deduce you might have correctbatteryhorsestaplegithub as your password for GitHub etc., but from the random password it's impossible to deduce the other random passwords, as they are completely unrelated.

On the other hand, if your computer gets infected and someone steals both your password manager database and the password (e.g. using a keylogger), they have keys to the kingdom. That's a completely different risk model and requires access to the operating system the password manager is installed on. Against this you need other measures like multi-factor authentication.


Keeping user session alive - security considerations

I smell two "bad smells" in this approach:

First, you should never trust the client.  Storing the username on the client-side and then trusting the client to send it back honestly does not strike me as wise.  You've already discovered that this could allow someone to access a single page under a different username.  That already sounds a bit dubious, and how do you know there aren't worse attacks?  I would recommend against any scheme that involves trusting, even if only for a little while, the client.
Second, the usability of this sounds problematic.  Popping up dialog boxes that interrupt your flow is really annoying.  Either cut off their session, or don't.  Personally, for most websites I think there is not a great deal of danger in keeping their session open for a long time, if they've left a tab open, and I think the usability benefits of not forcing users to re-login are worth the security risks but that's for you to decide.  My only suggestion is to avoid pop-up dialog boxes that interrupt your flow.  Of course, I'm not an expert on usability.  If you want a more expert opinion, you can ask on User Experience.SE.

Update (11/14): I understand that you added the dialog box for a reason, but I still think it's probably not the best solution from a usability perspective.  If the solution is that users who were in the middle of data entry were losing data, then there are other solutions that seem like they have better usability.  Example: you can use Javascript to have the web application auto-save the text they've entered every 30 seconds, so that if their session times out on them, they can log back in and their text re-appears.  Or, you could extend the length of the session.  Or, you can detect user activity on any tab (typing, etc.), and only expire the session after 60 minutes of user inactivity.  Asking User Experience folks might lead to other suggestions as well.  I realize this is off-topic for this site, so I'll leave it at that.

I don't immediately have an attack that breaks your scheme and shreds it to ribbons.  But these "bad smells" leave me with some concern and make me think that you haven't followed good practices for defensive design in web applications.


How could someone create a Facebook account with my email address without stealing it?

Besides the fact the facebook account could have been created there is also the posibility that the emails are phising attempts that only look like they are coming from facebook.

So do not follow links in the emails, it may not be facebook they go to.

The idea in another answer to reset the password to prevent the account from being accessible by those who created it is good, but go to facebook directly to do it. You may find out that facebook have no knowledge of the email address (a recover password mail may never appear).

If you follow a link in the mail and alter the password to your usual password, you may very well just have given phishers access to all your online logins.


Tricking a program with more privileges to do something that the owner of the program didn't intend is called privilege escalation.

When a privileged program reads data from the outside, it should verify that this data is harmless. This is called data sanitization. For example, a setuid program that executes an external program should verify that the program it's executing is the intended one. In this case the program depends both on the comamnd string ls -la /dir and on the value of the PATH environment variable¹. The only safe values for PATH are those such that the first entry for ls and any other command that the program might execute is the intended one; in practice that means completely ignoring the external information (the value of PATH in the environment) and setting PATH to a known safe value.

Sudo removes most environment variables, including PATH which it sets to a safe default. This makes it easier to write safe privileged components by using sudo rather than a custom setuid program for privilege elevation. A program run through sudo starts up with a safe value for PATH. You can still get things wrong, of course. For example allowing a user to run sudo ./example allows them to run whatever they want since they can create an executable called example in the directory of their choice.

¹  And LD_xxx variables used by the dynamic linker, but the dynamic linker of the setuid program wipes those when it sees that the program it's linking is setuid.


Since raw emails are not encrypted, what you can read in an email could have (conceptually) been read by anybody. However, to read the email, the attacker would still have to connect to the HTTPS server, which leaves tracks (the IP from which the attacker connects will be known to that server -- of course, that IP will probably be that of a Tor exit node). The link-in-email system prevents passive-only attacks: the attacker has to send some IP packets of his own at some point. This is not a huge increase in security...

Usually, promoters of solutions such like the one you describe do it for security, but not your security. They want to know when the email was read. This is a preventive measure against people who read embarrassing emails and then claim they never received them. It won't be much of a proof, but it may be sufficient to counter evasive maneuvers from some uncooperative co-workers.

If you want a system which guarantees that only a specific individual will be able to read the email, then you need to define what specific individual you are thinking about. In the world of computers, everybody has a computer, and they are not immediately indistinguishable from each other. People have physical identities which are not part of the computer world, so a link must necessarily be made at some point. Standard secure email solutions like S/MIME do that through a public-key infrastructure: a recipient is defined by being "the guy who controls the private key corresponding to the public key which is in that certificate". This moves the problem of physical identification to a single preparatory step during which the certificate is issued.

A possible model is that you met the recipient in person once, and he gave you his business card; on the card is printed the fingerprint of his OpenPGP public key -- you then find the key from a public key server, and check the fingerprint. There are many variants on this concept, but a non-computer physical contact is necessarily involved.


Does the Facebook app use HSTS for Android/iOS? No. It doesn’t need to. HSTS is specific for telling web browsers like Chrome, Firefox, etc. to interact with their web service via HTTPS only.
A mobile app will have HTTPS hard coded in the app itself making it the only option. I believe Apple requires this for any apps and for Android it looks like they are moving towards HTTPS for apps as well. Android HTTPS.
If you are developing an application yourself and want users to only use HTTPS then you would simply call your backend services using only HTTPS and have that coded right into your application whether android or iOS. Example: https://api.example.com/data
The reason why HSTS isn’t needed in the mobile app environment is because in the web browser a user can go to a base url like example.com over HTTP. The user has more control in a web browser environment on how they want to navigate to your website. Also indexing and back linking to your website, people can specify which protocol HTTP or HTTPS when linking to your website. So that’s why you need HSTS in a web browser environment to tell the browser, “only talk to me in HTTPS even if someone says they want HTTP” but in a mobile environment, as a developer you are the one that gets to specify HTTPS in the code in your app for interacting with the backend service. Users don’t need to manually navigate to a url because that is all coded in the app Facebook or you built. The users just have to open the app. So as a developer you get more say on how the app should interact with your web service. It’s your app, your client, you tell it what to do but you didn’t build Chrome or Firefox, it’s someone else’s client so you need to tell them via HSTS how it should interact with your web service.


Start with the Emulator and Simulator, which are part of the standard SDKs. If you prefer certain environments over others, you will gravitate towards a reliable framework for pen-testing these platforms.

For example, with an iOS app, I always start with the iOS Simulator after building the code in Xcode. I set my Mac OS X system HTTP and SSL/TLS proxy to localhost where I run Burp Suite Professional. Then I launch the app and utilize the Xcode DTrace functionality found with the command-line dtruss tool. I tend to look at the plist files with the smartphonesdumbapps tools.

With Android apps, it's similar. These days, I go back and forth between IntelliJ IDEA and Eclipse, but both have very usable Android SDK integration points. For Eclipse, it's ADT. I like to launch the Emulator via the ADT. I like to interact with the filesystem and memory using the DDMS, which is primarily useful for debugging. When it comes to software tracing though, I tend to hop on an adb shell and strace the processes I'm interested in, along with a simultaneous logcat. For proxying, I typically use a DNS blackhole to create a transparent proxy to Burp Suite Professional using the Emulator's -dns-server flag. It's useful to look at the manifest in ADT as well, especially to look at the permissions and intents.

Much of this changes if you do not have buildable source. Even worse, you could be targeting an app that has self-modifying or self-checking code. In these situations, you will need an approach that involves disassembling and decompiling the app. For iOS, the class-dump-z, otool, otx, and i386codedump tools are a safe bet along with IDA Pro. You can find a lot of information on decompiling Android apps, although ARM debuggers and IDA Pro will come in handy for those apps that are heavily invested in self-modifying or self-checking code protections. There is a lot of information about malware and tools around malware on the Android platform that are tied to this sort of problem. For example, there's a mobile-malware mailing-list.

Some other great resources happen to be the developer documentation combined with hands-on work. Pluralsight and Raywenderlich have some excellent tutorials that cover these platforms -- I've been through all of their material. There are many books from Syngress and OReilly books on Android and iOS -- many of which that cover security and forensics topics quite in depth. There's a book on Cocoa Application Security from Wrox Press that is also worth a look, albeit dated. Most books covering the basics of the base languages (Obj-C and Java) will be useful, although it's also good to understand where mobile app languages and concepts converge (e.g. PhoneGap, MonoTouch, et al).

** UPDATE 3/26/2012 **

I tend to use similar tools, although I've branched out more to the DTrace-Toolkit and iprofiler/Instruments for iOS Simulator apps. I tend to do a lot more work using cycript on a jailbroken iPad 2, which has been an eye-opener (especially along with class-dump-z). For Android, I believe that I forgot to mention the Activity Monitor, which is very useful for launching intents.

A lot of the runtime can be viewed/analyzed/modified by using runtime Obj-C or Java/Smali, so knowledge of these languages and their platform specifics on target devices is not very optional.

Occasionally, I am asked to pen-test apps that are another format (e.g. AIR for iOS/Android, HTML5, Titanium, NDK, et al) but compile as native apps. In this situation, it is best to build (as would have the original developer) and/or reverse engineer every component using a combination of binary, static, and dynamic analysis. This may require use of Flash Professional or another IDE/build-tool.


What is the purpose of publishing the source of a web application?

If I have a big company that sells a product, I might not want to disclose its source because people may just copy it and sell it, thus decreasing my profits.

But if my big company provides a service by means of a Web application, it's very likely that I can publish the source code, because the actual value of my service lies somewhere else (in a large and complex infrastructure, access to databases,...).

What's more, I could actually earn the trust of additional customers by showing them that my code can be audited by lots of people, including the customers themselves. For example, this may show to the customers that my code doesn't store their data in plaintext.

That said, any Web application is extremely likely to contain vulnerabilities that can be found by an attacker, with or without access to the source code. If you don't publish the code (barring bug bounties), the good guys can't disclose vulnerabilities to you. If you do, they can. Of course, bad guys exist in both cases.

Finally, realize the hacking world isn't split in purely good and purely bad guys. Some people want companies, and the whole world, to know they're good at finding vulnerabilities. Perhaps  getting their name on a Hall of Fame (that's why bug bounties are good) or on the credits section of a Github repository is enough to satisfy this "need". If you don't publish your code, the only way these people have to get what  they want is to attack your application or sell a working exploit against it.


Biometric device instead of password - signature security

Generally, method 1 is more secure as it is possible to ensure the fingerprint image never leaves the scanner thus cannot be trivially copied via compromised software. Some anti-tampering technology can be employed to make it very expensive to try to extract data from the device.

Your concern about how the scanner proves to the computer that the actual fingerprint is scanned is normally done by making the device hold some secret. For example, when a fingerprint is enrolled, the scanner also agrees on the secret key with the host. Each time a user needs to be authenticated, the host will ask the device to perform some operation that is only possible with the knowledge of the secret.

Such a scanner is typically tied into some other security hardware (like a TPM on PCs or security co-process on phones) so that the correct fingerprint activates the security key for data encryption. All of these are handled outside the main CPU so data cannot be practically decrypted without the fingerprint.


It is not a hotspot, it was made to look like one while attacking my network

It sounds like some (or all) of what you are seeing may be related to the fact that Comcast/XFinity uses it's customers' routers to provide public wifi access.  See the following links for more information, including how to disable this on your router:

https://money.cnn.com/2014/06/16/technology/security/comcast-wifi-hotspot/

http://wifi.xfinity.com/

https://www.xfinity.com/support/articles/disable-xfinity-wifi-home-hotspot


Google Chrome on Android constantly being redirected

Firstly, go into Chrome -> Settings -> Search Engine and check the search engine. There is a malicious search engine bug that google is yet to fix involving JS execution via the Default Search Engines feature.

Then, grab everything from /data/data/com.android.chrome/. The chrome cache is in a directory named cache under this directory.

Next, wipe the entire directory from your phone manually and do a full factory reset.


Searching encrypted text with encrypted queries

The only usable solution that I am aware of that hasn't been found to have serious code vulnerabilities is ZeroDB (www.zerodb.io) which allows running queries over encrypted databases.

The ZeroDB developers have provided instructions on how to test in Python on their website in the Documentation section.


Couldn't credit/debit cards easily be made more secure?

All very good questions. There is a lot of nuance and history here that short answers have to elide that is worth the research if one is interested.

  Couldn't such leaks be avoided if the merchants didn't keep the details of online transactions? In other words, why payment processor like Visa or Mastercard can't act as a middleman?

Merchants are not supposed to store payment details following a transaction- except in rare cases where users are engaging with merchants to create a recurring transaction, e.g. a subscription- but some nevertheless do, in contravention of requirements they have to follow for taking card payments, colloquially called PCI after the organization that administers them (which is sponsored by the payment brands, Visa and Mastercard). These improper storage points have of course been compromised leading to significant fines and costs for the merchants involved.

However, storage, whether proper or improper, is far from the only attack point. There has to be machinery to capture the card details from the cardholder at the point of sale and communicate that with the various banks involved- at minimum the acquiring bank, the bank with whom the merchant has a relationship allowing them to collect cardholder payments- and cardholder banks, the banks responsible for approving the use of credit or confirming the availability of funds for debit. This communication is often logistically brokered by payment processor middlemen, which operate in various layers, specializations, and relationship shapes, depending on industry and so forth.

All players in the communication flow have to adhere to PCI requirements around "cardholder-data-in-transit" but as one might imagine they all do better or worse at this and all have been subject to compromise as well.

At any rate- the answer is that attackers go where the weak points are. There are many weak points in the overall payment machinery, so many that the Federal Reserve last year started a national program to systematically improve both security and latency in all payment systems (see https://fedpaymentsimprovement.org/).

That certain weak points have been exploited and there has been a recent history of public shaming is not an indication that there are not other weak points lurking in the system.

  Why doesn't it work that way?

The mere presence of a middleman does not provide better security, though it can reduce the attack surface- or simplify the attacker's problem, depending on how well they do their job.

However, what you are really referring to is a better protocol- which can provide better security- and that's what we are seeing with the rise both of chip-based payments (called EMV in the US) and its online cousin tokenization. Both of which work by using cryptography to create single-use payment credentials at the point of sale, rather than always distributing a reusable payment credential. Lots to google there if interested.

  Is a CSC (card security code, a 3 or 4 digit code printed on the card) always required when buying online and if not, what does it depend upon if it's required - is it up to merchant whether to ask for it?

It is not always required when buying online. The decision is usually the merchant's, which can experimentally weigh:

reduction in sales due to consumers having to enter more data to complete a transaction
reduction in fraud due to what might be loosely called an additional factor that is slightly less available to fraudsters
reduction in fees from acquiring banks on transactions that use the CSC vs those that don't.

  If they are always required, why is it such a big deal when millions of credit card details leak due to a hack?

It's a big deal from a news perspective because, for various reasons, more consumers pay attention to issues of this kind now. Largescale leaks from several years ago that were far more damaging in absolute terms received far less media attention.

It can also be a big deal for the retailers involved from a business perspective because the rules- called PCI, as mentioned earlier- have gotten tighter, and fines and penalties for violating the rules have gotten larger. So when retailers violate the rules, like storing cards when they should not have, the impact can now be materially significant to their business.

It's less of a big deal from an operational or fraud perspective, because all the parties are accustomed to the remediation- send consumers new cards, invalidate the old ones, rinse and repeat. Expiration dates have gotten shorter on newly issued cards, so loss of a large number of cards is to some extent just an extension of normal workflow for card providers.

  Why the CSC number is only 3 or 4 digits? Couldn't fraudsters try all the possibilities? Or is there a maximum number of attempts before a card is blocked?

The code that performs system of record transaction processing checks for various indicators of real or attempted fraud, including multiple attempts against the same payment instrument within a particular time frame.

There is also a lot of geographical rationalization- use of the same card number in two physical Point of Sale systems in different geographical areas in the same day will get heightened scrutiny.

But there are many other signals here- payment fraud is a very interesting and active application area for machine learning.

  Why is the CSC number even printed on card? Wouldn't it be better if there was just one password not written on the card that is used to authenticate both types of transactions?

Convenience, all around.

It is absolutely fair to say that the CSC number does not rise to the level of being a second factor, but it is also absolutely fair to say that a second factor is still infeasible in the real world when it comes to usability and convenience. Even security people still struggle with second factors, much less ordinary consumers.

A more common "second factor", so to speak, is required use of cardholder zip code, which is much more common than required use of a CSC.

My sense is that on balance, CSC is attributed with a relatively modest reduction in fraud at relatively modest infrastructure expense, but that it has not been considered a success. Chip payments and tokenization are much bigger impact.

  When I read headings like "10 millions of credit card numbers leaked" do they actually mean only the numbers? Isn't the numbers alone useless without data like expiration date, name of the card holder, which as far as I know are also used to authenticate a transaction?

A reported compromise will be of whatever the compromised party considered to be sufficient data to capture payments. Card number and expiration date are the only data points that are always required by payment processors and other downstream systems. Other data points like name, address, zip code, phone number, CSC, email may or may not be, depending on the particular details of the merchant, the business, their provider relationships, and so forth.

Most of the use cases around additional data collected at payment time are for marketing rather than strictly for payment verification.


Which methods should I connect a VPN, via that-vpn-app or through an VPN configuration on network manager linux?

Unless a proprietary/custom VPN protocol is used, a VPN client application will typically be a wrapper around the same existing programs and protocols. If you were to study the application, you would very likely see that an OpenVPN binary and OpenVPN configs are used.

The application's main advantage is most often the user experience. Instead of manually downloading config files or finding what IP address you need to connect to when you want to switch location, the program can display high-level choices (e.g. VPN server location) through a fancy UI.

Another feature of these programs is that they sometimes can manipulate your firewall rules to ensure there are no leaks. Of course, you could set this up yourself if you wanted.

Otherwise, the performance and behavior of the VPN should be identical to that of OpenVPN alone.

However, any additional application you run on your system can increase your attack surface, creating opportunities for privilege escalation; e.g. the client application may run under your user, but may also require a root level daemon to manipulate your network configuration. Additionally, like with any application you install, you must trust it to not be malicious, although this is usually not a concern from well-known companies.


Most efficient way to scan for webservers

Nmap itself can do everything you asked for, in an efficient way using simple NSE scripts.

Scan large numbers of servers for port 80: nmap -p80 -PS80 --open
Do a GET request for each root page: --script http-fetch --script-args 'maxpagecount=1,destination=/tmp/files . This unfortunately doesn't work well for multiple targets as of Nmap 7.60, but it wouldn't take much of a fix to make it do so. Other scripts you may be interested in are http-grep, or http-headers.
NSLOOKUP on each address: this is unspecific, but Nmap can do:

Reverse DNS (PTR record) lookup, done by default unless you use -n. If this is all you want, use -sL for "list scan."
Forward lookup of hostnames/domains. Nmap does this by necessity, but if this is all you want, then use -sL -n.


If a provider sees the last 4 characters of my password, can they see it in full?

There's several possibilities.

They could be storing the full password in plaintext, and only
displaying the last 4 characters to the support person.
They could be hashing the password twice.  Once hashing the full password,
and again with just the last 4.  Then the support person types in
the last 4 to see if it matches the hashed value.  The problem with
this is that it makes it easier to brute force the full password
since the last 4 characters are in a separate hash, reducing entropy.
They could be hashing the full password, and storing the last 4 in
plaintext.  Obviously this makes it much easier to brute force the
password if an attacker gaining access to the password database knows     the last 4 digits.
Something else where the last 4 characters are stored in some way
that's discover able, such as encryption that Mike Scott mentions below.  If the secret to unlock the 4 characters can be discovered, this is as bad as plaintext.

All scenarios are very bad, and greatly reduce the security of the system.   It's not possible to know which scenario they're using, but each of them shows a lack of consideration for security breaches.  I'd advise caution if this is a site where you care about your account being breached.


Heartbleed and heap management - Why user data and passwords are kept in memory?

In C, when you are finished using memory on the heap, you free() it which makes it available for use elsewhere. free() doesn't clear/wipe the memory to all zeros, so the next caller who asks for that memory will get the memory with its sensitive contents still intact unless you explicitly zero it before calling free(). Programs also often implement their own buffer/memory structures (e.g. OpenSSL's BUF_MEM) which depending on their implementation may or may not zero-out memory after use.

You are correct that sensitive data should only live in memory for as long as a need to know exists. It is best practice to zero out sensitive memory in these cases.

I can't say for sure in the case of OpenSSL since I haven't had an in-depth look at the code, but it could have been reading from memory that was still required, or memory that was no longer required but not zero'd-out, or a combination of the two.

More reading:

Optimizing compilers can remove calls to zero memory
Memory Deallocation issues in C
Zero and forget -- caveats of zeroing memory in C


What kind of wifi network does not have any protection and yet it's not an open network?

They could be using MAC-based filtering which only permits specific network cards to access them.  The AP has to know the MAC address of each network card permitted to access it.  That would be a little unusual for ISPs, but certainly could happen.

Such protection is trivially defeated by forging the MAC address of the client.  MAC addresses have traditionally been meant to be hard-wired and unique, and just as traditionally been so easily fungible as to defeat any security method based on it.  Nonetheless, vendors still include it as an option.


Do android spyware apps comes attached with games or mod apk files?

Generally, apps on Android are very limited in terms of what they can do to other applications and the system. In order for other apps to be installed by your app, you would have to specifically grant the app permission to do so (in Android 11), and you would see prompts about all that anyway. So unless you blindly clicked on prompts and changed settings, nothing else was probably installed.
As pointed out by @yeah_well, it is much more likely that the app itself is spyware. But if you are comfortable with the level of permissions you have granted to it and accept the risk of using it, then there is probably not much to worry about.


Drive-By Download, or a Basic Trojan Horse?

  Do I get any benefits (even if only minimal) when omitting automatic downloads for certain file types?

If you mean you're trying to detect and prevent a drive-by-download when it happens to you, then you get minimal benefit if your attacker doesn't know another method, but it's essentially a security theatre.

However, what you're describing is not a drive-by-download.

There are lots of different ways to initiate a drive-by download. Take for example the ability to write any type of file with an extension to the user's local storage, and then rename it to an actual executable, then execute it.

Currently, you can, for example, use the HTML5 cache to write an executable with any extension to the user's computer, then rename and execute the file with Flash. Pretty ebil, huh?

What exactly is a Drive-By Download?

I've updated this post based on Uwe Keim's new comments:

  "Sorry, probably I described this in my initial question too confusing. We provide a service where users can upload files and let our system send emails to other users with a download link that goes to our website. Basically to "send" files that are too large for email attachments."

This isn't really a drive-by-download issue, although it could potentially lead to it.

A drive-by-download is when you force a user to download and execute a program automatically without their input. They are unaware of the file's existence, there is no download dialog, and it happens behind the scenes. While yes, you can serve them a malicious file whose existence they're aware of - which they execute on their own - that is not a drive-by download. That's a run-of-the-mill basic trojan horse.

How Could Someone Cause A Drive-By Download On My Users?

I am adding this block just in case, since I want you to understand how a drive-by-download could work; I do not feel you understand what it is. You may ignore this section if you have viable XSS/SQL injection protection already.

This could be done with an XSS/SQL injection vulnerability. Make sure you check, not sanitize, your input. One way is to make sure you have a regex of the file name which allows all of the common file names (A-Z, a-z, 0-9, period, apostrophe, brackets, etc. This isn't really sanitizing your input: it's simply disallowing bad inputs.

Apostrophes should be allowed in file names as well. Use prepared statements and not string concatenation in any form. You'll want it to be ascii only. When outputting your file for download, you'll want to replace any special characters.

Assuming you are using ORM, or serialized data, you'll be fine when outputting non-breaking characters. It is highly recommended, though, that you sanitize the output to replace all potential page-breaking tags with their respective html entities because - dons tinfoil hat - you'll want extra protection just in case the attacker somehow got around your regex check due to a funny exploit.

You do NOT want these tags getting injected on your pages: <% %>, <?php ?> <script>, </script>, or anything with < or >

null/length check + Regex input check + prepared statements/parameterized queries + output sanitation = Neatness.

Are malicious drive-by-downloads detectable based on file type/mime type?

Anyone could give a file any extension or mime-time they want, and reassemble it later with an exploit, so no, it's not detectable with this method unless the malware author made a serious mistake.

Furthermore, you also need to worry that your anti-virus won't detect it right away. Most anti-viral programs can be defeated through obfuscation, sadly. If relied on alone, it's essentially a false sense of security these days, in many areas.

And the method you're describing is not a drive-by-download; it's just a trojan horse.

Serving Executables That Download Automatically

Most websites do not try to get you to automatically download a file. Malware websites do. Most websites legitimate will implement something that says something like, "If your download doesn't begin in X seconds, click here."

This is a better idea for usability reasons mainly, but it will not offer any extra security at all, although it may prevent people from leaving your website for various reasons.

I think you could get away with presenting a download page that tells the user exactly what they're downloading, rather than an automated link. That could be a very convenient thing to track down some , and if the user

Conclusion

It's a bit of both. A little security, and some security theatre.

It will not provide much benefit unless someone exploits your download system and injects a fake download into it, but they could do that whether you implement this change or not, though.

However, presenting a download page could be very convenient, as it could potentially prevent the user from downloading the wrong file.


Best security algorith for storing passwords

IMHO the best password storage function is scrypt.  This algorithm became my favorite key derivation function after reading Stronger Key Derivation via Sequential Memory-Hard Functions.  Scrypt can use an arbitrary amount of memory or cpu time.  This feature makes scrypt very difficult to crack using an FPGA or GPU.  It should also be noted that ChromeOS uses scrypt in an interesting design.

A java implantation can be found here.


Is it dangerous to be within range of a compromised WiFi network, even if you don't connect to it?

If your device isn't connected to the network, either because WiFi is turned off or because your device isn't configured to automatically connect to the network, nothing on that network can affect your device.

However, an attacker may create a network with the same SSID and PSK as one that your device recognizes, such as the WiFi network used at your workplace. Your device will likely connect automatically in that situation.

To mitigate this risk, assume all networks have something listening, even if it is just the router itself. Make sure all your network traffic is encrypted using a VPN.


Virtual Machine are not always foolproof although I do agree that they are pretty useful but there has been cases of whereby the "guest" vm can access to their "host" machine. Read up

For sandboxie, some malware will crash and it will omit an error message when you run it on a sandboxie but it won't when you run it on an environment without the sandboxie.

For someone who just wants to be totally secure, using another physical machine without any internet access and no private and confidential information are stored at that physical machine would be deemed good(although there can be cases whereby malware will spread through thumbdrive).

In your case in wanting to help your friend, I would recommend you to try Windows SteadyState(freeware) if you are on Windows XP or Windows Vista or you can try Deep Freeze (commercial). Basically, it creates a snapshot of your current system configuration, and you can do anything with your computer but when you reboot, the system will revert back to the previous snapshot so your computer will be the same as before you did anything to your computer. Do note that your computer needs to be in a clean state before you create a snapshot that will be restored after each reboot. Otherwise, your computer will still be infected.


Can webpages using the Google plus button get my name?

No, the page you access does not get your name or any other data from Google.

If you have a close look the button is in an iframe. An iframe is technically like a webpage in another window. Because of the same origin policy those pages can not interact with each other.

The only way the page can get personal information about you is over the Google API. Like if you login to this page using your Google account they can request data about you but this transfer needs to be granted by you.


During the SSL handshake,

If the server requires a digital certificate for client authentication,
the server sends a "client certificate request" that includes a list of
the types of certificates supported and the Distinguished Names of
acceptable Certification Authorities (CAs).

(quote is from a reasonably lucid explanation of the SSL handshake by IBM.)

The client then compares the certificates in its store against that list to see if it has any signed by the CAs that the server listed.  If it finds one, it will send it, usually after prompting the user whether they want to send it.  Presumably if there were multiple matches it would ask the user which to send (if any).

(Updating to answer comment below with regarding GAE):

This page appears to be a Google employee saying that App Engine doesn't support Client Certificate authentication.  Now, that's dated 2010, so I wouldn't take it as the final word, but it is a flat-sounding "no".

This question is looking for the same thing, and that person got redirected to look into OAuth2 via Google Cloud Endpoints.  Perhaps that would serve your needs well enough?


Career path: Is going for PMP along with having a rich experience in the InfoSec field a good career move?

A project management certification will help your career if you want to move from a technical to a managerial or project management role. If you want to stay technical then it has no real value, and even makes you look less technical. I have a PMP and I have to say it's not particularly valuable, but it is an important credential to have as an IT management consultant.


Sending noise over wire, using hashes of noise to carry data

In an authoritarian dystopian environment, the authorities aren't going to permit every network transmission they can't prove is harmful, they're going to use a default-deny rule, and only permit transmissions they can prove are safe.  In such an environment, you'll need to disguise your transmission as a known-safe protocol, such as HTTP or Telnet.

Even without that, your proposed protocol is statistically identical to strong encryption.  Any dystopian authority worth their salt is going to block anything that looks like encryption.


Is CKN in MACsec considered as secret value?

No, the CKN is not considered secret; it's public information. It's openly (unencrypted) transported as part of the MACsec Key Agreement (MKA) packets as identification for the secure Connection Association (CA). See IEEE 802.1X for more details.


java keytool - how to modify a keystore's Owner and Issuer information?

TLDR: You can't modify a cert; you can and should replace it.

You can't change anything within a certificate because it is digitally signed precisely to prevent anyone from changing anything in it. However, you can get a new certificate for the same keypair but with new dates, different name(s), and possibly other changes.

No real CA issues a cert with either Owner (which is really Subject) or Issuer containing only 'unknown', much less both, so this is almost certainly the dummy (placeholder) self-signed cert created by keytool when it generates a keypair.

If you want to get a 'real' cert from an established, trusted Certificate Authority aka CA, you can do so with keytool; in fact this is the normal process:

keytool -genkeypair: create keypair and selfsigned cert (in keystore)
keytool -certreq: create Cert Signing Request aka CSR (for keypair in keystore)
send CSR to CA along with evidence of identity (often, especially for SSL/TLS server, an Internet domain name, but sometimes another kind of identity) and if applicable payment
receive/fetch new cert from CA along with any applicable 'chain' or 'intermediate' certs
keytool -importcert: install new cert and chain into keystore

See the Java manual at e.g. https://docs.oracle.com/javase/8/docs/technotes/tools/unix/keytool.html#keytool_examples . The details of steps 3 and 4 vary depending on the CA you use, and all CAs I've ever seen have customized instructions for issuing a cert to a Java system, often listed under Tomcat as the 'typical' Java system, tailored to that CA. You effectively have already done step 1 but with the wrong subject name, and need to complete the remaining steps with one variation:

in step 2 keytool -certreq add the option -dname 'newnamefields' (use " on Windows) to specify the corrected requester/Subject name for the CSR.

General info about cert names is on the same page at the heading X.500 Distinguished Names. If this cert (and key) will be for an SSL/TLS server, the Subject name should be or include 'CN=servername' where servername is not the name of a person as described in the manual, but instead the name, or a wildcard (in first component only) matching the name, of the server as it is accessed by client(s). For public/Internet servers this is usually a Fully Qualified Domain Name aka FQDN or in rare cases an IP address, but some intranet or LAN environments use other names.

Otherwise: if you want to create a new selfsigned cert, keytool does not have an option for that; you can write a program to do it, but it's easier, though a bit roundabout, to use OpenSSL instead. You can also use OpenSSL to request a real CA cert with some options that keytool doesn't support. If you are on Linux you most likely already have OpenSSL; on other Unix you may need to install it, almost always from the vendor's normal repository/channel/etc; on Windows (unless Windows10 with WSL) you will need to install the ShiningLight package. In outline this is:

keytool -importkeystore -srckeystore jksfile -destkeystore tempp12 -deststoretype pkcs12 # convert from Java-only JKS to standardized PKCS12
openssl pkcs12 -in tempp12 -nocerts -out tempkey # convert from PKCS12 to OpenSSL's 'private' PEM format
For selfsigned: openssl req -new -x509 -inkey tempkey -validity days -out newcert and answer prompts for the name (or instead specify -subj 'namefields'); see man req on Unix for details, or on the web or earlier version as applicable. Then keytool -importcert -file newcert -keystore jksfile [-alias entry_if_not_mykey]
For CA-signed: modify the OpenSSL config file (or a copy) if need then openssl req -new [-config conffile] -inkey tempkey [-subj 'namefields'] -out csrfile then submit this CSR to a CA in the same fashion as for Java above. When you get a new cert and its chain, do one of the following:

4a. keytool -importcert the needed chain cert(s) to a different entry, or  to different entries individually from the top down, then the EE cert to the same entry, as described for Java

4b. combine the EE cert and its chain certs, all in PEM, into a single file, and keytool -importcert the whole chain to the same entry

4c. use openssl pkcs12 -export to combine tempkey plus the (new) cert and chain into a single file say newp12, per man pkcs12 or here or earlier, then keytool -importkeystore -srckeystore newp12 -srcstoretype pkcs12 -destkeystore jksfile after deleting the old entry, or just deleting the file if this is only (desired) entry


Data wiping. SSD VS eMMC how are they the same and how are they different?

I don't believe TRIM has a major effect on memory clearing; it's wear-leveling that's the main issue, as it means the OS could 'overwrite' data while it still exists on the physical media. TRIM is just telling the drive that a certain area isn't needed, and the drive can do what it likes with it.

SATA drives (including SSDs) have the ATA-SE commands, which allow you to tell the drive to delete everything on it, including any 'reserve' areas. Whether this is implemented correctly is another question, though. I don't think eMMC drives have this.

As eMMC drives are generally a single package, it's harder to remove the flash chips (or solder onto the pads directly) and read the flash without going through the controller - this could make it slightly more difficult. It's probable that eMMC controllers have debug modes that allow read-out of the flash, though.

I'd have to agree with childofsoong that you can't be certain that it's all gone without complete destruction.


Are AWS EC2 key-pairs compromised when an EC2 instance is compromised?

What kind of cryptographic primitive is used for EC2 key-pairs?

The keys that Amazon EC2 uses are 2048-bit SSH-2 RSA keys.  They are asymmetric, "public key" pairs.  The public key goes on the instance(s) you wish to authenticate to, and the private key stays with you.

If one instance is compromised, do I need to be concerned about the
key-pair allowing access to the other instances?

No.  Because only the public key is compromised, there is no concern; that's why it's a "public" key.  Even when you authenticate to a compromised instance, the private key itself is not shared with the instance.


Intercepting and reading SSL traffic generated by Android

You should be able to add a root certificate to the keystore in Android under the settings.  Note that adding a certificate to the keystore will require a password or pattern lock to be turned on on the device.  You can access the keystore under Settings/Security normally, though some customized versions of Android may have moved it a bit.


You question isn't very clear. You wrote:

  I'm connecting to that server via VPN (wireguard).

And after:

  I do not route all traffic through that VPN, only DNS requests.

So, if the HTTP stream between your client and your server isn't routed throught VPN, then the connection isn't encrypted.

At contrary, if you route the traffic to your HTTP server throught the VPN, then it's encrypted.

Nevertheless, keep in mind that traffic between your VPN gateway and your HTTP server will remain clear.


Not if it's your normal browser. He could see if the page in your browser has gone out of focus (e.g. if you open a new tab, click over to a new window, etc.), but that is pretty much it. One course my girlfriend had to endure in the past required her to use a dedicated browser which was a bit more invasive, but she was able to cheat using a secondary computer nonetheless.


Anything the user inputs (or can control the value of) is untrusted. Always filter and validate.

Anything dynamically generated that may consume user controllable data is untrusted. Always sanitise.

Basically anything is deemed untrusted if you are not 100% in control of it.

  i'm sending data (user name) from the serverside that has been extracted from database. Is this data going to be trusted data?

No, apply the rules above and you will see if the original username was not properly validated and/or the output is not sanitised the user name, could be <scrip>alert('xss')</script> basically a stored xss value or any other value the user or bad actor wants.


My site just got hit with a SQL injection attack, how can I tell what they were doing?

First you should check if your mysql user has the FILE privilege. If so, consider the system completely compromised.

The injections you provided along with the error 'duplicate entry' are a clear example of error based SQL injection.

PHP's mysql_query doesn't support more than one query, so it's not possible to insert/update/delete from a select query in your application. But if your application has an insert/update/delete query that is vulnerable to sql injection (which is very likely) then it is possible to tamper with the database.


Before we talk about the single user mode, let's talk about what you can do when you have physical access (in the context of your question, of course). On a Mac, the first thing to boot from another media (LiveCD, USB stick, etc.) and navigate to /var/db/dslocal/nodes/Default/users and modify root.plist and disable the password. On Linux, I'd do the same with the /etc/shadow. Finally, on Windows, the same can be done with \system32\config\sam file.

As you can see, single user mode or not, the result is pretty much the same - total compromise. Single user mode is just a convenience to make maintenance easier.

Finally, no, single user mode dose not exist in Windows anymore (starting with Windows Vista). In Windows XP, the Administrator account used to be activated and left without a password but left hidden. Booting into safe mode (F8), used to show the Administrator account.


Facebook security algorithm: Locked out of my own account after resetting password

The answer to the question, is there some way to report the issue, is yes! You can report the incident here:

https://www.facebook.com/hacked


I'm wondering why AJAX is not used to log in nor register in most of the pages and it's used PHP reloading the whole page. Is it about security, or it's just that it's not practical at all?

Ajax is not a special thing regarding the transport of the login data, because it is a HTTP request done in the background instead of the foreground. Thus if done correctly the security should be the same.

But, with a normal foreground HTTP request you update the full page and thus take the current browser tab fully into a different security level (i.e. logged in vs. logged out). With Ajax you update only part of this page. If you are not careful you might mix this way content from different security levels on the same page so that data from different security realms might interact with each other.

Thus using a new page instead of updating an existing page is not only the more simple approach but also the one where it is easier to verify that everything was done correctly.


SSL was invented in 1994, and now it is 2021. Surely this is a solved problem?

Surely SSL/TLS had evolved into something much more secure, with stakeholders such as IETF TLS working group, CA/B forum, browser vendors, etc. being more sophiscated at securing the connections for ordinary users.
There is one possible solution for your customers. With this solution, you don't have to mass-install certificates on all machines, but you do have to periodically pay for some ISP service.

Get a public domain name, and a certificate for it,

Resolve the domain name to your private intranet server address.

That's obviously less painful to configure individual computers, but nonetheless require a technical staff to setup the server.
Additionally, per advice from my CA provider, setting up OCSP stapling on the server can improve performance when browsers verifies the validity of the certificate.


How to sandbox students' Python 3 code submissions for automatic assignment evaluation on Windows 10?

pysandbox is an implementation of a sandbox in Python. It is designed to execute untrusted Python code (in our case, code submitted by a user) within a constrained environment which can be configured by a pysandbox deployer.

Please refer to this link for more information:
https://www.software.ac.uk/blog/2017-11-23-executing-python-code-submitted-web-service


Best way to do security testing for a server behind nginx proxy

I agree that Burp suite is a good tool, but there are a lot of different types tools to perform penetration testing. Tools are useful for pentesting but you need to understand the application and environment. Then you can select the right tools for the job.

You indicated that your server isn't a web server, but is behind a nginx proxy, so what kind of server is it? Understanding the environment and "attack surface" is the first step.

Once you understand that, you need to look for vulnerabilities and attack vectors. Once you find a vulnerability, then you need to understand if it is exploitable.

Much of this can't be done by a tool.

Check out "Engebretson, Patrick. The Basics of Hacking and Penetration Testing: Ethical Hacking and Penetration Testing Made Easy, Second Edition. Syngress Publishing. © 2013" for a good overview of pentesting.


What you are trying to do is to add an additional "security by obscurity" layer on top of the normal authentication layer which is the "security by design" layer. Yes, it will increase the amount of work an attacker must perform.

There is a simpler solution to achieve the effect which you desire. KeePass allows you to use a key file in addition to a password. The key file can be any file on your system. There are literally thousands of files already on your system. The attacker needs to get both the password and the file correct. Since KeePass does not write to the file, you don't have to worry about any of that timestamp problem.

By choosing to write an app to perform the function, you need to make sure that there are no bugs in the app, you must also remember to run the app to reset the metadata every single time. These are additional problems which can be avoided. Bugs can have catastrophic consequences. (E.g. Overwriting your actual password database)

Make sure to choose a file that does not get modified through system updates. I am currently using an mp3 file from my vast 10GB music collection. Good luck finding the right one.


I'm not aware of any plugins specifically that do this, but in the case of the Google search engine, or something like Norton DNS or google DNS it's all done on reputation.

For example if you report a page as a phishing page, then a hundred other people also report it, when that search result comes up in google it will say that the page is potentially unsafe. If you're using a service such as Norton DNS then it will direct you away from that page.

I would imagine any browser plugin or functionality would do something along the same lines, checking each URL against a reputational database before advising whether it is a safe link or not.


Instead of JSONP, why can't we bypass Same Origin Policy explicitly?

... ask the browser to send an unauthenticated request

The browser don't know how authentication is done by the server. It can be done with session cookies, client certificates, the clients source IP address or simply because the client is able to reach the server at all.

For example you often have a company Wiki or bug tracker inside the companies intranet, i.e. not directly reachable from outside. If an attacker would be able to make an "unauthorized" (i.e. no cookies) XMLHTTPRequest to these internal resources from an external page (for example using a targeted advertisement) then the attacker could exfiltrate important internal information from the company.


Is displaying email addresses in an application log file allowed under GDPR?

The goal of GDPR is about protecting personally identifiable information (PII) as much as possible. The interaction of a specific user with your application are pretty sure such PII.

If you really need to log this information you should inform your user about this process, i.e. the purpose of the data collection, how long the information gets stored and who gets access to the data. And you and whoever you sell the application to should never use the data for any other purpose as agreed to by the user. And of course you need to properly protect the information against misuse, i.e. use outside of the specified purpose. This specifically but not only includes if someone hacks into your application or server and steals this data.

Since use of the data is limited and protection (and fines) can be costly, it might be easier to not store these information in the first place. An alternative is to at least pseudonymize the PII as much as possible, i.e. in a way that the logged data are still usable for you but that no association to a specific user can be done even when having all the logged data. But since it is not really clear what you use these logs for no recommendations can be done for a specific process of such pseudonymization.

Be aware though that simply replacing each unique email address with another unique identifier might not be a sufficient pseudonymization. Depending on the data you log it might be possible to create user profiles and based on specific traits in the profiles associate these to real world users. See AOL search data leak for an example how such simple pseudonymization attempt went wrong.


Will two intermediate CAs signed by the same root CA trust each other's signed client certs?

TL;TR: it depends on the exact configuration of which CA's are trusted in each service.

Authentication means that a trust chain to a locally trusted CA can be built. This means:

If service A trusts only intermediate A but not the root CA then it will trust any certificates signed with intermediate A but no certificates signed with intermediate B because no trust chain can be built from intermediate A to certificates signed by intermediate B. Similar is the behavior of service B.
If service A instead or additionally trusts Root CA then it will trust any certificates signed directly or indirectly by Root CA as long as it has knowledge of the necessary intermediate certificates. Thus if client B sends its client certificate and also the issuer certificate (i.e. intermediate B) then service A will trust it because it can build the trust chain.

Note that the last statement is only true if service A does not employ any additional restrictions. These restrictions might include a limit for the length of the trust chain: if service A accepts only certificates directly issued by its trusted CA then sending the certificate and intermediate for B will not make it trust client B. The restriction might also include an explicit distrust of intermediate B in which case it will also not accept the certificate from client B.


Open wireless network and OpenWRT isolation function - any risk?

In term of risk, enabling isolation can only be an improvement if you start with an open router without any kind of protection.

Isolation should protect you from DNS poisoning (like the example you wrote) but also from ARP poisoning (see: http://arxiv.org/abs/1404.2172).


How to encourage responsible disclosure (and react appropriately otherwise)

How can I promote responsible disclosure of security vulnerabilities found by researchers? That is, how can I encourage them to collaborate jointly with me, not releasing details until a fix is prepared, while simultaneously ensuring they feel they are respected for their hard work and they get the credit they deserve?

I think you are on the right track so far with this point. The most important thing is to have an easy way for security researchers to contact you about security flaws. Keeping them involved in the process of fixing the bug is just being polite. If the bug is serious enough and you are able to afford it (which might not apply to you since you are a startup, offer the researchers a bug bounty for their efforts).

The worst thing you can do is be rude to the researchers and ignore their efforts to work with you on fixing the bugs. See this very hilarious case.

  In case someone takes the full disclosure route, how can I react (be alerted of the vulnerability as soon as possible and then take appropriate mitigation measures) in the most timely and effective way?

You are also on the right track for this. I don't think there is a more effective method of discovering full disclosures about your software's vulnerabilities besides monitoring the various vulnerability databases available. You might want to look into subscribing to the feeds that such databases push out and use a regex filter to sort through irrelevant information.

If someone does something like this, I'd say the most important thing you should do is keep your customers informed. You might feel that this would negatively impact your reputation, but trust me, it would be a lot worse if your customers get hacked as a result of your software.

Keep them updated on the progress of the fix. If a timely fix is not possible, suggest alternative methods of mitigating the damage.


Appending multiple Google dorks in a single query

Using brackets around the dorks separated with '|' and using AND operator for the sitename would do the trick.

For example, the solution to the example problem in question would be:

("index of /htdocs" | "Below is a rendering of the page up to the first error." | "[function.getimagesize]: failed to open stream: No such file or directory in") AND site:example.com

This would search for those three dorks in example.com.

Answer credit


Are Anti DDoS server farms really effective?

In my experience, there is no such thing as 100% DDoS protection. The largest DDoS cyber-attacks ever recorded have reached and exceed 1Tbps. Even if some company claims that they can protect you against such an attack, that would be a false statement.  The Internet of Things is perhaps the best mean an attacker can use since the level of security on those devices is extremely low. Therefore, the attackers have all the means to launch extremely large DDoS attacks nowadays.

In principle, the quality of the DDoS protection services you get, depends heavily on how much money you are willing to spend. Most of the ISPs that offer Internet Breakouts to web hosting companies, bundle some sort of DDoS protection. Some Web hosting companies might not choose to do the “washing” of the traffic on the cloud though, and might prefer on-premise devices (for example there are basic DDoS mechanisms on some firewalls or some load balancers).

If you are concerned about having good DDoS protection, I would suggest you to talk to the Web Hosting companies you are interested in, get answers in writing on what kind of DDoS protection they are using and evaluate which one is the best. I would strongly suggest picking a company that has a hybrid DDoS protection environment, meaning that they do traffic “washing” on the cloud first using some 3rd party vendor, and at the same time they also have a second layer of protection using on-premise devices which also acts as a detection mechanism. In general, I would stick with a company that uses well-known vendors in the DDoS protection field such as Incapsula, Arbor, CloudFlare, F5 Networks (ASM Module on Load Balancers), etc.


Is auth with a number of memorable questions better than regular password auth?

The trouble with any scheme like this is that people in general are rubbish at choosing good questions, let alone remembering the answers.

In theory there is a huge amount of entropy as there are multiple instances of essentially infinite questions and possible answers.

In practice a significant number of people would still choose common questions and answers. First pet, car, street, place of birth etc

These answers are then vulnerable to both dictionary attacks and social engineering and/or open source research.


What is the purpose of associated authenticated data in AEAD?

As a very general rule, the purpose of associated data (hereafter "AD") is to bind a ciphertext to the context where it's supposed to appear, so that attempts to "cut-and-paste" a valid ciphertext into a different context can be detected and rejected.

For example, suppose I'm encrypting the values that I insert into a key/value database, and I use the record key as AD.  What does that do?  Well, first of all, mechanically it means now that whenever I decrypt the value, I must present the same key as AD or otherwise the decryption will fail with an authenticity error.  So my application will have to perform that step in order to decrypt any of the data correctly.

Second, and more deep, is that by using the key as AD, I've thwarted one sort of attack an insider—say, the database administrator—could conceivably carry out against my application: take two records in the database and swap their values.  Without the AD, the application would happily decrypt these, and blindly assume that it read the correct value for those keys.  With the key as AD, instead the application would immediately notice that the values are not authentic—even though the attacker never actually modified them—because they're occurring in the wrong context.  That's just one example out of many possible, but applications of associated data tend to have that flavor.

One important detail that people often miss from examples is that the associated data doesn't necessarily have to be stored or transmitted with the ciphertext.  Any context-dependent non-secret values that the honest parties are both able to correctly infer can be useful as associated data.  For example, if the parties are executing a complex protocol that's been formulated in terms of a state machine, such that every correct party can always tell their own state and that which an honest counterparty should be in, then those states—even though they're implicit to the protocol—can be used as AD.  This is the sort of thing that makes AEAD suites so attractive to designers of protocols like TLS—it's a tool that can be used to cut down on the complexity of a secure protocol.


What needs to be encrypted for FIPS 140-2 compliance?

FIPS140-2 deals only with the proper way by which a cryptographic module must operate and be protected from attacks. One can be just compliant with his modules, or one can be compliant AND validated with her modules. There are 4 different levels of compliance, 1 to 4, with a higher level more protective than a lower level. Getting validated is an expensive undertaking, usually done by external security labs.
FIPS140-2 does not talk about what data need to be encrypted by an application. Various standards bodies, unique to each industry segment of interest, establish the requirements, procedures and processes of data protection and encryption specific to that industry. For example, PCI DSS by the credit-card industry, HIPAA by the health care industry.
These bodies may or may not demand that an encryption module would be FIPS140-2 compliant, but certainly being such is a prudent choice - at least from a liability point of view.

Some relevant comments from infosecisland.com:

"I have done FIPS 140-2 compliance tasks firsthand with:
OpenSSL, OpenSSH, Sun Java 6, Apache Tomcat 5.5 and 6.0, Mozilla NSS.
I can tell you that none of these modules are operating in a FIPS 140-2 compliant mode by default, getting them into a FIPS 140-2 compliant mode is not trivial, and operating in a FIPS 140-2 compliant mode is not always a good idea for compatibility reasons."
"Allow me to clarify the business cases that someone will want to invest in the time and expenses necessary to achieve FIPS 140-2 validation, not just compliance:
When you want to sell anything that is cryptographically relevant to the DoD or any government working group that looks to the DoD for security specifications. This is not going to be your typical enterprise customers, but specific government entities that require the assurance of cryptographic integrity that FIPS 140-2 provides."

So, if you don't have a crytographic module in your application, FIPS140-2 is not relavant to you. If you do encrypt some parts of your program, like data or a comm protocol - either because it is the proper thing to do or being required by a standards body or by customer requirements or by regulations - and you need to be FIPS140-2 compliant, that encrytion routine/module needs to either just adhere to the FIPS specs or even be fully validated.


It sounds like you are trying to design a HSM that is custom tailored to work with Bitcoins. I believe these are called hardware wallets. There are already many existing implementations of them as well as designs for do-it-yourselfers.

As far as the security of such a device, the devil is in the details. You'll want a device that requires you to enter a passphrase to decrypt the data on the device.

For physical security, besides x-ray attacks, there are also cold-boot attacks, resoldering the board, and numerous other attacks. Various software and hardware strategies (eg: encryption) can make these attacks harder, but you'll never have full security without physical security.

It seems to me that the biggest risk for such a device is that of loss of your Bitcoins. If you device gets lost, damaged, or is otherwise unusable, you'll need a strategy for recovering your secrets and your Bitcoins. This is likely an offline, physical backup of some kind that you can store in a safety deposit box or something.


CVE-2018-0886 mitigation for an unpatchable RDP server

Require the client to log into a VPN before connecting to the server. Expose the RDP port only to hosts connected through the VPN.

This will protect you not only from CVE-2018-0886 but also from other RDP vulnerabilities, such as CVE-2019-0708 (BlueKeep) and those that will continue appearing in the future, if no malicious actor is able to get into the VPN.

Please note this is a big if. Even the computer from which the most trusted user might get compromised, you should really require a VPN and patch the vulnerabilities. But missing the later one, at least you should implement the former.


Enforce single-domain licenses for a WordPress theme

This is already partially answered in comments, but the simplest thing to do is to have a secret UUID string stored with the code and the current domain, and then that be used as a payload to the API side of things.

The tricky part here is the type of system you're using.  When you state a Wordpress theme, Wordpress doesn't exactly give kindly to 'closed source' on themes.  By this, I mean that the theme itself is designed in a way which is not kind towards 'secret' code.  Any user who has access to the code given to them can patch around any security mechanisms embedded in the theme coding.

While this is less of the case with compiled code/binaries (in which case you need to decompile to 'patch' out security controls), it remains the case that anything you give to any user can continue to be 'patched' to circumvent any security controls put into place, with enough effort.  This ultimately means that you have to trust that your users who are given the theme are not going to try and circumvent your controls; those who wish to, however, will be able to do so.

Your simple approach is likely the best approach, but keep in mind that there's ways to 'patch' around such controls, and with enough effort even the most robust 'security controls' for licensing items can be circumvented, with enough time and effort to do so; this ultimately means you just have to trust your users to not be trying to circumvent your security controls.


First, you didn't specify if this is for servers or for desktops.

But I'll assume servers for the moment. To directly address the logging aspects of PowerShell logging... Yes, it can log cmdlet calls. I believe 3.0 and above do this with the right GP settings.

Secondly, event logs aren't encrypted and ACL's to them are easily modified. So I personally suggest using a SIEM to remotely monitor them, so that you can look for some of the most important cmdlets, such as ones that deal with remoting, event log modification and anything relating to permissions and report that back to your monitoring tool so that in the event the local logs are modified by a malicious actor, you have the info back in your monitoring tool.

However, if you are truly interested in hardening against PowerShell exploits, you'll need to consider hardening PowerShell itself.

Ask yourself a few questions pertinent to your situation...

No matter what, upgrade to at least PowerShell 4.0. No questions on this one.
Do you want ANY user on the machine to run PowerShell scripts remotely? If not, disable the WinRM service and block ports 8495 and 8496.
Do you want ANY user to be able to execute PowerShell scripts locally?
If not, rename:

3a). C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe and powershell_ise.exe to some other name.

3b). C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe and powershell_ise.exe to some other name.

Depending on your answers to the above, this is a good start to mount a defense. But do note, this is just one layer of many. If they have admin to the box, they can rename, re-enable everything back to default, including wiping all logs.

Depending on what SIEM you use, let's assume Splunk for the moment - you can add a source to the prefetch file for PowerShell which is generally: %systemroot%\prefetch\powershell.exe.*.pf  and look for ".ps1" in the file. You can also monitor for last modified and other pertinent fields.

This is especially effective on systems which are still using PowerShell 2.0 and  don't have the ability to upgrade to PowerShell 3.0 or higher to take advantage of Windows PowerShell event logs.


Most vendors preseed the TOTP token and provide a seed file (with the secret key) to be imported into your system. Of course this leaves a bit of a doubt, if the vendor handles the key delivery right.

If you would go for HOTP and not TOTP I would recommend the yubikey, since it is to be initialized in the most easy way.
Other devices are built for cost efficiency and programming is sometimes not a feature. (You would need an interface and the hardware vendor would have to provide software, so that you can actually programm the device).

However, there are some Feitian TOTP tokens (C200 and TOTP display cards), that can be programmed. But you need to invest into an programming device or software, that needs to be purchased.

There is the vendor longmai, that also provides TOTP tokens and I think you could programm these using the NFC protocol - but: I think they do not have any ready made software -> a lots of programming on your side.

Bottomline: I think programming TOTP tokens is only worth the effort if you going to use several hundrets of tokens. If you are only looking for a token on your own, take a look at the yubikey.


If no firewall is blocking packets between Kali Linux and the Windows Box, Hydra should be able to successfully notify that the provided credentials worked

root@kali:~# hydra -t 1 -l username -p password1! rdp://192.168.190.130
Hydra v8.3 (c) 2016 by van Hauser/THC - Please do not use in military or secret service organizations, or for illegal purposes.
Hydra (http://www.thc.org/thc-hydra) starting at 2018-05-24 11:05:56
[DATA] max 1 task per 1 server, overall 64 tasks, 1 login try (l:1/p:1), ~0 tries per task
[DATA] attacking service rdp on port 3389
[3389][rdp] host: 192.168.190.130   login: username   password: password1!
1 of 1 target successfully completed, 1 valid password found
Hydra (http://www.thc.org/thc-hydra) finished at 2018-05-24 11:06:00


In apache, why www-data owner of a web application directory is safer than recursive 777?

The risks from a folder with 777 privileges and from a folder with 755 privileges owned by www-data are slightly different. In the case of the 777 folder, if an attacker is able to get control of any user on the server, they will be able to modify and delete the uploaded files. In the case of the 755 privileges, if they are able to compromise the www-data user (or any user in that group), they can still modify and delete the uploaded files, but if they compromise any other user, they can only read the contents of the files, without being able to make modifications.

If all users on the system are in the www-data group, there is no difference, but that isn't usually the case. For example, if the server runs a database as well as the website, the DBMS will usually run as a user in a different group. In this case, a flaw in the DBMS allowing code execution would not allow an attacker to directly affect the uploaded files, unless they could escalate their privilege to a member of the www-data group or root user.

For finely grained permissions, look at options such as Access Control Lists (ACL), which can allow more specific rules than the basic owner-group-everyone approach, or SELinux, which can implement mandatory access control to files and folders, meaning, for example, you can say "only processes with a particular flag can write to this folder". In either case, these are very easy to shoot yourself in the foot with - test carefully before applying to a live server!


How secure are wi-fi networks on a voucher system?

There is an inherent difference between WPA2 which should authorize and encrypt, and a captive portal with some key, which can only authorize. If you switch off WPA2 you loose encryption over the air, which is a bad thing, since now people can spy on your transmissions.

So its like on Airport WiFi´s and other public places, do not use any communication which is not encrypted. Already before, of course, all people joining the WiFi with the WPA2 could do that.

On the other hand, was the other answer tells, the portal can help avoiding people joining over and over again with the same key, when they shouldn´t. In the end the best solution would be to have username and password login with a Radius server behind, to establish enterprise-grade user authentication and key exchange.