Does MAC address filtering provide security? Sometimes I need to configure the router and choose which devices can connect to my network (MAC address filtering). For example, limit connections to 3 specific machines. But for an advanced user, it is possible to get my MAC address and change it easily (e.g. On a Linux machine using a simple command line macchanger --mac xx:yy:zz:tt:aa:bb wlan0)

According to gowenfawr, if one of my 3 machines isn't connected, it's possible for an advanced user to reconnect in its place.

To get more security features, what is the right configuration of MAC address filtering: enabled or disabled?

MAC filtering doesn't provide an high security. An attacker can simply see which devices (and their relative MACs) are connected to your network, and spoof one of theese MACs. When he changes it to his machine, he can connects to your network without any problem. In conclusion, MAC address filtering doesn't increase your security.


Deciding CVSS v3.1 scope parameter for a XXE vulnerability I have a web application which is vulnerable to XXE attack. The impact of this vulnerability is, it can do a port scan by sending a malicious XML that does a request to a specific host+port in the server instance/network.

When calculating the CVSS score for this issue, I have the following concern for 'Scope' vector of the CVSS score 3.1.

When calculating the scope, CVSS Score specification says, if the resources managed by the same security authority, scope is unchanged. However, security authorities of the resources(vulnerable web application and the impacted resource that access via the XXE vulnerability) in the aforementioned issue, can be changed along with the deployment. As per my understanding, the impacted component might be managed by the same security authority or another authority depending on the server deployment.

In that case how should we proceed the scope value to calculate the CVSS score? What is the common practice for this kind of scenario?
Or else, is there anything that I have missed when understanding 'Scope' definition?

What does "Scope" mean?

The scope essentially asks whether the vulnerable component is also the affected component. Let's use a SQL injection as a simple example:

The vulnerable component is the web application. It just concatenates input into a pre-written SQL query and sends that to the database. The database is the component that is actually affected by the vulnerability. Afterall, it allows an attacker to arbitrarily read and possibly even modify data.

So to make it simple, it asks Who screwed up? and Who suffers the consequences?. If they are the same, the scope is unchanged. If they are different, the scope changes.

How does this apply to XXE?

As you said in your question, the vulnerability allows an attacker to perform a port-scan on your internal network. We can quickly see that the vulnerability lies within the web application, but the other hosts on the network are now affected as a result. This leads to the conclusion that the scope has changed.


Basic scrypt question Suppose we throw a regular password into scrypt to generate some data. Scrypt allows us to specify how large the output data should be.

My question is, to take an extreme case, if we ask for a 1 GB data from scrypt, would it be possible somehow quickly to generate the final bytes of this output from the first bytes?

In other words, is there a threshold "x bytes" at which I "should probably not ask scrypt for more than x bytes"?

Update: Let me put it a different way: If I tell scrypt to produce 1 GB of data, make the first x bytes of the result available to the public, and use the final 48 bytes (as key and IV) to encrypt sensitive data using AES-256-CBC, am I in trouble? Trouble, in the sense that I have defeated the purpose of using scrypt? Does the answer depend on x?

You should not ask for more output from scrypt than you need.  The CPU/memory cost of scrypt hashing is not dominated by the output size, but rather by the setup process (in Wikipedia's explanation of the algorithm, the values "N" (CPU/memory cost) and "p" (parallelization parameter)).  The output is generated by a single iteration of PBKDF2, using the values from the setup phase of scrypt as the salt.

For the same reason, generating partial output (say, the last few bytes) is only marginally faster than generating the entire output: it's possible to generate only selected subsets of the output of PBKDF2 at low cost, but you need the entire input to be available to do this.

PBKDF2 generates its output as a series of blocks by concatenating and iteratively hashing the password, seed, and 32-bit block number.  For output of less than 2^32-1 blocks (128 GB for PBKDF2 as used by scrypt), revealing part of the output has no impact on the security of the rest of the output.  After that point, however, the output starts repeating itself.


Why does Double Submit Cookies require a separate cookie? According to https://www.owasp.org/index.php/Cross-Site_Request_Forgery_(CSRF)_Prevention_Cheat_Sheet#Double_Submit_Cookies:

  When a user authenticates to a site, the site should generate a (cryptographically strong) pseudorandom value and set it as a cookie on the user's machine separate from the session id.

(emphasis mine)

Why does the CSRF token need to be stored in a separate cookie if the session id is:

a random value (a value the attacker cannot guess)
stored in a cookie (a value the attacker cannot read)
generated by the server (a value the attacker cannot write)

Why not simply use the session id as the CSRF token? You'd still submit the value twice (once in the cookie, once in the form) and compare the values, but wouldn't use a separate cookie for the CSRF token.

The reason is that this allows the main session cookie to be marked HttpOnly (so it won't be accessible to Javascript).  There is some debate about how much value this adds, but HttpOnly seems to make some kinds of attacks harder so is arguably a useful hardening measure.

If you didn't use a separate cookie, but just re-used the session ID for these purposes, then Javascript would need the ability to read the session cookie, and we wouldn't be able to mark the session cookie HttpOnly.  By using a separate value, it becomes possible to mark the session cookie HttpOnly.

This is why they recommend using a separate value.


Is it possible to disable SSL over SMTP/POP to the mail server that enables SSL/TLS? I'm using thunderbird where I can check the option whether I will use SSL/TLS or not. However in my company's server, SSL/TLS is enabled both on POP3 and SMTP.

Is it possible to disable SSL/TLS on the client side?
If so, what's the advantage/disadvantage of doing it?

There are different protocols for retrieving the mail (POP3, IMAP) and for sending mail (SMTP). All three of these protocols can have different flavors regarding the use of TLS: no TLS at all (by default port 25 or 587 SMTP, port 110 POP3, port 143 IMAP), upgrading a plain connection to TLS using a special command like STARTTLS (SMTP, IMAP) or STLS (POP3) or using TLS from start with a different port (port 465 SMTPS, port 993 IMAPS, port 995 POP3S).

Given the variety of options there is usually a way to choose the proper option at the client side. But the choice at the client must match what the server actually supports. Many (but not all) mail servers today are configured to not accept authentication credentials over a plain (unprotected) connection and enforce the use of TLS is authentication is needed - which is practically always for retrieving the mail and in many environments also for sending the mail.

  Is it possible to disable SSL/TLS on the client side?

Most modern clients default to the use of TLS. Disabling this is needed if the server does not  support TLS. Disabling might be possible if the server accepts both plain and TLS protected connections but not if the server enforces the use of TLS.

  If so, what's the advantage/disadvantage of doing it?

Disabling TLS removes protection and thus is not recommended if the server supports TLS. The only advantage of disabling TLS at the client  is to be able to make an (insecure) connection to a server which does not support TLS at all, i.e. where having an insecure connection might be considered less of a problem than having no connection at all.


How to view all the certificates that are loaded in to Chrome or any browsers or in to the OS? In Chrome, to view the certificate details of the site you are browsing, you can do a SHIFT+CTRL+I or navigate to: More Tools>> Developer Tools >> Security Tab.
But this will show you the details of the certificate of only the current domain you are visiting.

What I am interested is in browsing all the SSL Certificates that are held in my System (Windows or Mac).
Is it possible. If so, How do I access this information.

So, what I am looking for is
(1) Access or browse all the certificates installed in to chrome or
(2) Access or browse all the certificates installed in to any web browser
(3) Access or browse all the certificates installed in to OS (windows or linux).

Linux: Exact method is distro dependent. There are answers at https://unix.stackexchange.com/questions/97244/list-all-available-ssl-ca-certificates

Windows has no built-in viewer available, but there are third-party decoders such as CTLInfo (website).

Firefox: Tools > Options > Advanced > Certificates > View Certificates > Authorities.

Some quick stats you may find interesting: As of today, based on a quick manual count, Windows trusts 362 root CAs. MacOS/iOS trusts 175 root CAs. Firefox trusts 160 root CAs. Android trusts 147 root CAs.


Samba printer usernames and passwords , security problem Password leaks , printing from Linux client to windows based print server

When authenticating Linux users for using a windows share printer on their machine, the windows domain user-name and password of the user has to be entered in the add new printer wizard.

While troubleshooting a printing issue for a user , I came to know that these credentials are stored as plain text on the Linux client in printer configuration file.

Although this file , and the data in it , is user specific , but it is readable by root. Is it a good practice that the root is seeing all the windows domain credentials of all the users who authenticate to windows print server from their Linux client through their windows account?  ( the user-name and password is clearly in plain text ( if there are no special characters in it) in that printer configuration file (/etc/cups/printers.conf), in my case , the Linux client is centos6)

And what if the users are using those same credentials for logging in into some other services , such as facebook , gmail , etc

I really don't feel this is a problem and I will explain you why.
If anybody got root access they could just sniff the traffic so every time anybody tries to authenticate the attacker can grab the hash of the password.

If anyone gets root access they can start arp spoffing DNS spoofing spoofing spoofing, which makes your network if compromised even more compromised.

If anyone gets root access they can log the keystrokes /events /everything going on

*nix users tend to have the most updated version of common sense

Somebody with system on an windows system got the same amount of access.

Worrying about someone reading a clear text password for an account with lover privileges, when they got root, is like worrying about a crack in the floor when the building is crumbling around you

What you should worry about is people getting root ;)

Stay safe


Why do credit cards have bigger security than debit cards? So, I was getting another account at the bank, and there were all kinds of variety and options. To cut the story short, that bank worker and me started to talk about my options over debit card and credit card, and he said:

  Credit cards have much bigger security than regular debit cards.

Why and how is that so? Isn't security for all cards the same?

Credit cards are not more secure in the technological sense. Rather, they are safer (as far as an individual is concerned) in that it is much easer to deal with credit card fraud than debit card fraud, should it occur.
The reason for this is fairly simple. This article explains it pretty well:

The key difference: With a credit card, the card issuer must fight to
get its money back. With a debit card, you must fight to get your
money back.
DEBIT CARD FRAUD
According to the EFTA, your potential liability for fraudulent debit
card transactions is virtually unlimited. You have up to 60 days to
report a lost or stolen card under the EFTA. After that, you simply
lose whatever money was taken, even funds siphoned from linked
accounts.
CREDIT CARD FRAUD
Under the FCBA, your maximum liability for fraudulent credit card
transactions is $50. If you report your card lost or stolen before any
fraudulent transactions occur, your liability is zero. Many credit
cards promise zero liability for all fraudulent transactions.
“I’ve had my credit card information stolen and used fraudulently a
number of times,” says Tucker Spillane, a 24-year-old credit analyst
from New York. “Fortunately, my issuer almost always picks up on it
right away … usually because the activity is considered abnormal from
my typical spending habits. And they provide their own fraud coverage
anyway. I’ve never had to pay a dime.”

In practice, this means that if fraud occurs on your credit card, a simple phone call to your CC company saying "this charge is fraudulent" will likely resolve the issue on your end. They'll issue you a new card, the fraudulent charge will be removed, and no money will ever be deducted from your personal checking or savings account.
In contrast, with debit card fraud, the money is immediately deducted from your personal bank account. Even if you are ultimately not held responsible for it, it may take weeks or months for the money to be restored while the case is investigated. If you don't have enough money in cash or in other accounts left to cover day to day expenses, you're just out of luck.
EDIT to add: The above reference is US-specific. The situation is similar in many other countries but you should research the fraud protection laws that pertain to the country you live in.


Browsec - VPN and anonymizer According to Browsec's website this application can be used to Bypass firewalls. So in countries like Iran it seems a useful tool to bypass censorship and filtering.

For start using this application there are two version available, A "Chrome extension" and a "Portable Firefox" version.

My question is that is it safe to use Chrome extension of this software? can it cause security problem when i log in to Gmail and other password protected websites when i use this extension?

For example can this application secretly steal my passwords?

You are mentionning two Privacy issues here: Circumvention of censorship & password protection.

When it comes to government firewalls, it is wise to use widely spread softwares, as they have been tested a lot and are known to work as safely as you can find. The reference here is Tor and is used daily by insurgents in countries famous for their restricted internet access like Syria or China.

For your password privacy, this is not a topic I am very knowledgeable in, but I would advise you to not use any extension on your browser when typing a password. I would not even trust the browser itself. If whatever you are doing is highly sensitive, I would suggest using Tails that comes bundled with… Tor!

For your specific application (Browsec), there are several signs that you shouldn't trust it:

it is closed source (debatable, but you don't know what happens behind)
has very little review online (drawbacks of not being famous)
says they collect your data and may transmit it to a government
state that the traffic goes through their network, hence any access to an unencrypted website, they can read it all. possibly SSL protected ones aswell depending on implementation.


Risks of having SSH private key stolen I'm afraid this is quite a common question, but searching several times through the questions did not prove useful, and I'm really eager of knowledge here :D

I understand that keeping SSH private key well secured (strong passphrase, backup ecc.) is crucial, but I'm wondering about how much having it stolen is dangerous. An eventual attacker, once got our private key, could log into every server which has our public key in authorized_keys, right? But besides that, are there other things that he could use the key for?

Because even if you've secured your private key with a strong passphrase, the passphrase is the only protection of the key.

And since the encrypted key is only one part of an equation (your passphrase is the other half) it only needs enough computation power to bruteforce "crack" that key.

So, the key is as valuable as the passphrase to it.


Company claims hardwire connections are a security issue Someone to whom I am related is at a study camp for their desired profession. This person, let's call her Jane, is supposed to be studying rigorously for two months. The housing provided offers wireless internet connections, which are spotty and don't allow for fluid streaming of even low-quality video, or other useful tasks to studying.
Being that Jane wants to study in her down-time and look up resources as a reference to the material, she needs to access these materials and suffer with a slow connection. There are no provided modems or other ways to connect via Ethernet, and the student is expected to have some form of wireless connection computer, presumably.

Now, I want Jane to have the best possible studying experience, and I understand that they might deem this experience "the best to study in," so I called and claimed that I was interested in attending the camp myself, but I only have a desktop computer with no wireless card, and I expect a wired connection. After a few hours, I received a response saying the following:

  "We do not provide hard wire connections to our network because of viruses and stuff"

It was clear to me the information I was being relayed was second-hand, but acknowledging that I wouldn't be able to change anyone's mind about this policy, I come here to posit this question:

Exactly what security benefits could be gained by only offering a Wireless connection?

In this case, I'm assuming that the answer given to me was genuine and not just an excuse for them to not do extra work or anything of the sort.

Warning: Conjecture, because none of us know their actual setup.

It is very likely that the organization has their own network, which is hard-wired, as well as a guest network, which is wireless-only.  The two are separate networks.  This is a common layout because laying wire to desks is expensive, but worth it, for your own employees; broadcasting wireless is cheap, and worth every penny of it, for your guests.

When you asked about a hard-wired connection, they are answering the question of which network you'd be on rather than how you connect to the network.  And as the two are intertwined in their minds ("hard-wire is our network, wireless is guest network") they are answering very simply.

From their point of view, they don't want non-organization machines on their network, only on the guest network - because of viruses and stuff.  We can all understand that we wouldn't want random visitors on our internal networks, right?  So that would be a context in which their answer makes sense.

I would suggest explaining your concern to them and seeing if they can come up with a solution, instead of asking them about the solution you would expect to work.  It may be that they only expect guests to need enough connectivity for email and light web browsing.  If you explain that Jane needs more bandwidth for her study needs, and can convince them that it's a reasonable request, they're likely to find some way to help - even if it's just moving Jane to a room closer to the Wireless AP.


Ettercap man in the middle - ARP poison I am experimenting a bit with Ettercap in my local Wifi Lan.
I have a router (R), my pc (P) with Ettercap running on it and my smarthphone (S).
In particular am testing the ARP poison MIM attack and it seems to work, but I have some doubts.

I have been able to make R believe that P has the S mac address and to make S believe that P has the R mac address. So the router maps the smartphone IP to my PC mac address and the smartphone maps the Router IP with my pc mac address.

Now, when the Smartphone sends packets to the Router it uses the PC mac address and when the Router sends packets to the Smartphone it uses the PC mac address.
Let's suppose that the Router sends a packet that should be for the Smartphone, the smartphone will get the packet as am using WIFI so everyone can see everything but will it drop because Mac Address mismatching?
Also, the PC will be able to get Smartphone packets from the router, but layer 2 will not drop the packets as Mac address matches with PC Mac address, but as the IP does not match, the Kernel should not drop it?

I investigated a lot on this in the last few days:
By default, Linux drops packets with MAC address different from the NIC MAC address on which it gets the packet. Promiscuous mode should modify this behaviour.
If the ARP-spoofing attack has had success, the Man in the middle will receive packets from R and S (see my question for S and R definition), which will have P MAC address (this is the point of ARP spoofing) but different IP. You can read this packets using different tools such as Wireshark. I experimented with libcap (I used that library in a C program), that I think is used by Ettercap, and by that, you can take those packets and also modify and re-forward.
Please note that Ettercap does not enable IP forwarding by default doing:

echo 1 > /proc/sys/net/ipv4/ip_forward

Otherwise, the Kernel itself will forward the packets, but Ettercap also offers packets modifications and packets drop, that is possible just if the Kernel does not take care of those packets.


Shellcode that is smaller than 295 bytes that spawns a shell Metasploit payloads produce more than 300-byte shellcodes.

But I want my shell-spawning shellcodes to be less than 295 bytes.

Can anyone show me the links to these shellcodes?

Thanks.

A null free 211 byte bind shellcode is available from  Dafydd Stuttard, NGS Software.

http://code.google.com/p/w32-bind-ngs-shellcode/

I tested it in my labs, and it works well.


REST Services: Limiting the concurrency of a login endpoint Scenario:

A botnet is recruited to try to authenticate against a website or service with each bot trying infrequently using a common password and a list of 'real' email addresses, avoiding the account lock-out mechanism.

Mitigation:

Add a choke in code to limit the max concurrent login requests, plus a long delay in negative response.

The choke allows n simultaneous callers, tuned to normal traffic patterns. When a caller presents invalid creds, the service imposes a 6 second wait and returns 404.

Callers queue on a busy choke, and the choke will throw a 404 if the caller is left queuing for 6s, appearing like a bad login attempt. The choke is held for the entire duration, including the 6s wait for bad creds.

The idea is that if an unusual volume of bad login attempts arrive at the service, then the system will cludge-up quickly and most requests will queue and see a 404, even for valid credentials.

Assuming an attacker figures out that this mechanism exists, I'll have introduced a vector for easily clogging the service up and denying legit users from logging-in; the rest of the service will run fine and the 6s wait does not block a thread.

That said, the load-balancer has call rate limiting so that individual callers repeatedly hitting the login service and making it cludge-up, will eventually be stopped.

The alternative is not having this mechanism at all.

It's not yet live, we're pre-launch so I have no real-world insights. Is this a smart idea or dumb?

Luke

It is a bit difficult to judge if your scheme is reasonable or too much because it fails to provide any information on what the application does or what the value of the resource being protected is. Your security should be matched to your risk analysis i.e. the likelihood of attackers and the consequences should an attack be successful.

From your description, my main concern would be that you have built in a facility which would assist an attacker in performing a denial of service attack on your site. This may or may not be an issue, depending on your site and how the services are used. For example, if the site is one where users first authenticate and then receive some sort of token which they use for subsequent connections and if that token has a reasonable lifetime, then potential DoS issues may not be a significant problem (assuming most users are already authenticated and are able to continue to use the service). On the other hand, if the token has a short life time and users authenticate quite frequently, then this could be a problem.

From your description, it isn't clear that this is a 'real' threat your trying to protect against or a theoretical attack i.e. an idea someone has had and has decided to protect against. Do you have any evidence or reason to believe the site is likely to be targeted by a botnet style attack as you describe? While the attack type your describe does exist, a vast number of sites/services out there never see such attacks or seldom see them. It this is the situation for your site, it is likely that all this additional complexity brings you is possible inconvenience for legit users who forget their password and added complexity in your system, which has even more potential to create problems or hide vulnerabilities. Increased complexity can easily lead to increased false positives, which may well create frustration with your users and result in lost business.

As an example, just recently I assisted a company with diagnosis of a problem they had with their web application. Users were reporting increased frustration with lost sessions and having to re-authenticate too frequently. The problem turned out to be related to a security feature built into the system.

The application used a JSON web token to manage authentication/authorisation. The user would initially connect and provide their username/password etc and get a token which they could use for subsequent connections. The token had a 24 hour lifetime. All that was fine.

For added security, the token recorded the user's IP address and on each access tot the services, after decrypting the token, the service would check that the IP address recorded in the token was the same as the IP address the connection was coming from. On the face of it, this seemed reasonable. The app was mainly used from inside the corporate network. The company had a large site.

A recent network upgrade at the company resulted in the installation of approx 3000 new wirless access points and a new configuration of the wired and wireless network so that it used 802.1x across wired and wireless networks and a move from assigning IP address based on geographical location to one based on user role. One of the advantages of the new setup is that you could move around the organisation and keep your wireless connection active. As you move between access points, you may get a new connection and that new connection may have a new IP address, but to the end user, it looks like one connection. You can probably see where the problem was.

Due tot he change in IP address, the auth token no longer passed the IP test. The problem was an assumption that the user would retain the same IP  address the the lifetime of their connection. However, there was also another more subtle issue. As this application is used on an internal network, which is fairly well locked down with quite a reasonable level of security, the IP check was unlikely to be actually improving security at all. The idea of the IP check was to add additional protection against session hijacking by someone who was able to steal the users token. Although this can be a real risk in some environments, in this specific environment, this was a low risk and the protection was not of any real benefit. Worse still, the data which could be accessed by the application had low value - it was information useful to staff, but was not particularly sensitive and the consequences for unauthorised access were low. This was an example of a security measure being implemented which was based on a theoretical threat rather than a real threat in the environment.

The point is, you need to assess whether your control is really addressing an actual threat or whether it might be a reasonable idea which isn't of any real benefit to your environment and could potentially have a negative impact on legit users. Is the type of attack you describe and are protecting against a real threat in your environment? What would be the consequence if that type of attack succeeded? Will the potential impact on legit users be acceptable to the business? If you enforce strong passwords and use good hashing techniques, how likely is a brute force attack likely to work anyway? I suspect that your measures may be excessive and possibly not providing any real benefit, but that depends on the application.


Return-oriented programming: Address of system() contains NULL byte Disclaimer: I am asking this question solely for educational purposes.

I am trying to chain some function calls using return-oriented programming, exploiting a vulnerable binary which uses strcpy(). One of these function calls should be a call to system() (in order to execute some shell command). Unfortunately, the address of system() contains a NULL byte which will lead for strcpy() to stop copying the payload once this byte is observed.

My question therefore is: what is the best approach to solve this issue?

I've already checked libc for functions similar to system(), but have found nothing. Another idea of mine would be to call fork(), exec(), and wait() subsequently. This would however increase the complexity of the payload.

Is there some reason you need to leave the original process alive when your shellcode executes? Just call execve directly (assuming you can control the stack well enough), or one of its helper functions, which will turn the current process into your target process.

A trickier approach that might work is to use dlsym to retrieve a pointer to system, which you could then call with your target command. You might have to call dlopen first, though; I'm not sure about the semantics of dlsym. The corresponding Windows function GetProcAddress takes the base address of the loaded module (library or executable) as the first pointer, and dlsym might do the same; since you're using ROP you presumably aren't bothered by ASLR so that address should be predictable.

Finally, since you're using ROP, you can simply find one or more gadgets that let you arithmetically produce the desired address. There are many combinations of operands (constants in your shellcode, registers or addresses with known values at exploit-time, etc.) and operations (add, subtract, or, xor, etc.) that could be used to produce a specific value that contains a NULL byte from pieces that don't contain one, and ALU ops are short so it shouldn't be hard to find suitable gadgets.


Is it safe to add "Access-Control-Allow-Origin:*" to an API endpoint with custom authentication via header? Lets say I have a site at myapp.com that talks to the api at myapi.com. For that to work I have to turn on CORS. I want to do it like that:
Access-Control-Allow-Origin: *
and my API authentication is performed via a custom Authorize header (with e.g. Bearer token).
As far as I can see it is safe to do since an attacker website would have a way of obtaining this token or sending it automatically.
Is this correct?
P.S. I want to have a "*" to e.g. not have problems with localhost development or some other environments where myapp.com runs, e.g. stage-myapp.com, etc.

Theoretically, the Access-Control-Allow-Origin: * is just another defense in depth solution.
it's an easy way to make your endpoint have 1 more layer of security, especially from malicious websites tricking browsers.
it is by no means a sole solution to protect an api endpoint with (custom clients can just ignore the header. and   attackers will just work around it if they can)
So, if your API has proper other safeguards and monitoring you can set this header to the * value. (older browsers still ignore this header anyway).
Google and Facebook however have a dedicated team protecting there infrastructure from abuse, so they are bad examples to use for your consideration.
in the end its all down to your threat model... does it allow for this type of use r not. (e.a. is your system prepared for the potential abuse of your API or do you really need the additional protection that this header offers.
A possible workaround is making your API smart enough to return a custom header depending on where the request came from and limit that list to a whitelist of allowed domains.


Is it secure to use jQuery on the server-side for user input validation? I'm thinking about using jQuery on the server-side (node.js) to validate user input (filter tags, remove every attributes except href, rel, target & style, modify css rules which are applied directly to an element and remove javascript links). Example of js link validation below:

$(userinput).find("a").each(function() {
    if (/^j/i.test($(this).attr("href").replace(/\s+/g, ""))) {
        $(this).remove();
    }
});

Now is it possbile a the attacker to write some code which let's jQuery think it's not HTML by escaping, encoding or something? Is jQuery 100% secure for this operation?

UPDATE

For code intrested users.

You need to verify that the HTML is valid (e. g. proper nesting of ", ', <, >).  Otherwise different browsers will use different algorithms to "fix" it. This results in them seeing different things as tags.

Furthermore there is a high risk that you add too much to your whitelist. For example, the href attribute may contain active content, such as jaVascript:, vbscRipt:, java scriPt: amongst others.

On Internet Explorer there is an expression() function that can be used in CSS to execute Javascript.

I strong suggest to use one of the existing libraries to sanities user input, such as html purifier.

Please have a good look at the XSS cheat sheet.

Last but not least, keep in mind that an attack might work completely without JavaScript, by injecting a form asking for a username and password.


OpenSSL get key length of all certs I am trying to ensure that all certificates in a chain for a host have a key length of 2048 bits. Using openssl s_client, only the key length for that host's cert is given, is there a simple way to list the key length for all from the command-line, or is it necessary to download all the certs and check manually?

If you have a public-accessible server, use https://www.ssllabs.com/ssltest/analyze.html. Otherwise, see below for a script.

I am not aware of a s_client option that lists the key size for all certificates in a chain. You could use the -showcerts option to get all certificates provided by the server and check each of the provided certificates and assume that certificates in your trust store do not use small keys.

Note that some servers might be misconfigured to supply certificates in the chain that are not used (and incorrect). I remember seeing a site that would connect fine in Firefox, but fail in Java. It turned out that an old, expired CA was included in the chain along with the other certificates. Firefox would in this case just ignore that certificate as it found a valid certificate chain. openssl s_client -showcerts prints all certificates, even the ones that is unused (I have just verified that by appending a fake 1024-bit certificate to the chain).

The following script parses openssl s_client -showcerts output:

#!/usr/bin/awk -f
# Match all certificates
/^-----BEGIN CERTIFICATE-----$/ { in_cert=1; }
in_cert { cert = cert $0 "\n"; }
/^-----END CERTIFICATE-----$/ { in_cert = 0; }
!in_cert && cert {
    infocmd="openssl x509 -text -noout | grep -E 'Public-Key:|Subject:'";
    print cert | infocmd;
    close(infocmd);
    cert="";
}
# Print the verification result
/Verify return code/

Then use the above bits.awk with:

echo | openssl s_client -CApath /etc/ssl/certs \
    -connect example.com:443 -showcerts 2>/dev/null | ./bits.awk

The output looks like:

        Subject: CN=example.com
                Public-Key: (2048 bit)
        Subject: O=Trusted Certs Ltd., CN=Trusted CA
                Public-Key: (2048 bit)
        Subject: CN=Insecure
                Public-Key: (1024 bit)
    Verify return code: 0 (ok)

The first two lines are actually used for the chain verification, the last one isn't, but the script does not know that.


How should I more securely store files obtained by mirroring a website? Questions: what methods, tools, techniques, and procedures are recommended for securely storing files obtained by mirroring a website? What I mean is that I am looking for commonly known and accepted practices that align with the use-case outlined below, even if there might be varying points-of-view on which practices constitute a best practice.

Background: I have endeavored to provide as many specific details as I can provide on my use-case, though I admit that I struggle to provide more specific detail because this is an area in which my knowledge is limited. Thus, I am asking this question to better direct any future efforts, research, etc. As outlined in this question, I sometimes mirror websites to gain information of value to due diligence investigations. I learned from my previous question that things are often more complicated than expected. This question reflects my interest in thinking about the security implications of actually storing what I get when I use wget, curl, phantomJS, etc. So, I welcome your thoughts on best practices, actions you suggest I take, or general precautions. For example, perhaps it is a best practice to only store such files on an air-gapped machine, to convert HTML to a different format, or to simply avoid any Javascript files because they pose an inherent threat. As a reference, I use Ubuntu Linux.

Goals:

Retain text-based files for keyword and other types of searching
Retain image files for visual and metadata evaluation
To the best of my ability given the other two goals, store and interact with files in a secure manner

Filetypes encountered: these are the main filetypes I've encountered to date...

Documents: PDF, RTF, DOC, DOCX, ODF, TXT
Presentations: PPT, PPTX
Spreadsheets: XLS, XLSX, CSV
Images: PNG, TIF, JPG, GIF
Web: HTML, CSS, JS, PHP

The file types you listed and the goals you presented result in a huge attack surface. Assuming a sophisticated adversary, this gives a vastly increased possibility for exploitation. PDFs and PPT/PPTX are particularly problematic. If you cannot limit yourself to far fewer file types, you will need to isolate your activities, either using privilege separation or remote virtualization.
Privilege separation
This is a solution in the case that you need to perform this activity on your local computer. While it would be difficult to individually sandbox every single application you will be using, you can create a new user on your computer with few privileges:

Disable access to su and sudo from the new user, and do not use them as that user.
Do not su to your lesser user from root to avoid TTY pushback attacks.
Use iptables to disable network access for that user.
Set resource limits to reduce the amount of damage an exploited application can do.
Use Wayland instead of Xorg if possible, or Xorg with systemd-logind to run it as non-root.
Enable and use the Secure Attention Key when finished and switching to a new session.
Scan for and remove all unnecessary setuid or setgid files, as well as setcap files.
Use an auditing framework like auditd to monitor potentially malicious activities.
Apply general system hardening such as sysctl tweaks or hardening patches.

Depending on the level of sophistication of the adversary, this may not be enough, and even for an adversary of moderate capability, this is rather incomplete, but it is a starting point. As you have to assume (most likely correctly) that the applications you are using to access these files are vulnerable to arbitrary code execution, the question turns into How can I safely run untrusted code?, which is of course extremely broad.
Virtual Private Servers
An easier solution would be to use a VPS. You can run applications remotely on the VPS rather than on your own computer and interact with it that way. Even if the VPS is completely compromised, the attack surface area is reduced to that of your SSH client and your terminal, which is fairly small. As you will not be able to directly view images over SSH (at least not safely), you may want to convert them to a very simple (and difficult to exploit) image format before transferring it to your local computer and viewing it. An example of such a format would be the PPM pixel map format. This also works for viewing PDF files, as they can be readily converted into image files using various utilities.
The host of a VPS is able to access and modify anything on the VPS. If this is an issue for you (for example, if the files are extremely sensitive, or integrity is of utmost importance), you may not want to use a VPS. This is unlikely to be an issue, and as the website you have downloaded from is already (presumably) public, there should be no confidentiality issue. You can increase the confidentiality and integrity of the data by instead using a dedicated server, although that would be more expensive.
You should keep a local backup of these files, in the case that the VPS is shut down, so that you can restore it to another VPS later. The local files should be stored in an "inert" form that will not be susceptible to exploitation of any indexers or thumbnail generators you may have on your system. This can be done for example by putting the files in an archive such as tar.
As you will need to use command line utilities rather than graphical ones, you will need to find ways to access these files over SSH. Some examples which you can do remotely on a VPS:

You can convert PNG, TIFF, JPEG, and (non-animated) GIF to PPM to safely view it locally.
XLS/XLSX can be converted to CSV, which is fine on command line. There is a good vim plugin.
RTF, DOC, DOCX, and ODF can be converted to images, which can be securely viewed locally.
I am not aware of any way to view PPT/PPTX in command line, though you can analyze them.
HTML, CSS, and JS can be viewed in a text editor or run on a remote text-based browser.
PHP can be viewed in a text editor or executed using a command-line PHP interpreter.


Types of certificates for SSL I registered for SSL certs for a domain, and got 4 files in return:

interCert.crt
PKCS7Cert.crt
rootCert.crt
X509Cert.crt

I understand rootCert must be the root CA cert and interCert is an intermediate cert, but what are the other two? which one should I use for what purpose? I'm guessing one is a private key and one is the certificate? Why are they named like that?

It is not clear what is exactly in the files but might guess from the names:

X509Cert - probably the leaf certificate, i.e. the server certificate
interCert - probably the intermediate certificates
rootCert - the root certificate which should not be included in the server configuration. If this is no public root CA it have to be installed as trusted on the TLS client instead
PKCS7Cert - a container with probably all of these together in PKCS#7 format. See also What's the difference between X.509 and PKCS#7 Certificate?

  I'm guessing one is a private key

Probably not. The private key is usually created by the one requesting the certificate and kept private. Thus if you created a certificate signing request and got these files in response you should already have your private key. If not they might have included the key in the X509Cert file and/or the PKCS7Cert.

  I got it through the company IT department, they didn't give me any documentation, just those files.

I'm not sure how processes in your company work. But where I work the usual procedure is to ask the ones you got the files from on what to do with the files.


Username and password files in Kali I'm new to pen-testing world. I'm trying to learn how to gain access through telnet service opened on port 23.

I'm using Metasploit. The first approach I'm trying is using the telnet_login module to try a dictionary attack on the target.
I've seen that I should set USER_FILE  and PASS_FILE.

Does Kali have sample user.txt and pass.txt files?
Are there better approaches to attack telnet service?

Kali contains built in password word lists. They are compressed and can be found at:

/usr/share/wordlists/

I'm unaware of username lists, since usernames are usually pretty dependent on the format the service uses, and are typically fairly unique.

You can put together a simple non-exhaustive word lists for the users yourself containing obvious potential names such as:

admin
local
root
user
remote

Since you're using this to attack your own system though, you should already know what the username is, so you can just list that.

A brief reminder that you shouldn't use a tool like this to attack a system you don't have explicit permission to access. That would be a crime.


UserDataSvc_6038b: unable to disable this suspicious service On Windows 10, I just discovered a running service named UserDataSvc_6038b. It's description is as follows:

  Provides apps access to structured user data, including contact info, calendars, messages, and other content. If you stop or disable this service, apps that use this data might not work correctly.

Path to executable:

  C:\WINDOWS\system32\svchost.exe -k UnistackSvcGroup

Startup type

  Manual

I am unable to set this service to the Disabled startup state.

Edit: Using regedit, I was able to locate the service at:

  Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\UserDataSvc_6038b

and was able to set the Start value to: 4 (disabled)

While in the registry, I noticed the description for this service is:

  @%SystemRoot%\system32\UserDataAccessRes.dll,-14000

Googling this service returned "Your search - "userdatasvc_6038b" - did not match any documents."

This seems to be a unique, unwanted service to me. Does anyone have any advice on how to proceed?

If you're genuinely concerned that this service is/was malicious, there's a few things you can do:

Check the properties on the DLL listed.  Is it signed?  By whom?
Upload the DLL to VirusTotal.  If you have the same version as another source, you'll get this results page that shows 0/57 detection ratio, and an author of Microsoft corporation.

I don't have a Windows 10 box handy to check myself for the DLL in question.

If you search just for 'UserDataSvc', you'll find lots of other people asking about a service with that name + 5 hex characters.  Likely Microsoft has done something to make a unique service.  (Maybe it runs one per user on multi-user machines and 6038b is related to your account?  I doubt it's part of your SID...)

Just from reading about it, I'm fairly confident this is a benign (well, intended by Microsoft) service.


Are serverless web applications safe? From my understanding, if I use something like firebase to authenticate and download data from the database and host my static web app, which has client authentication system, all my logics are available publicly. Now it's understandable that no one can really do anything unless they are authenticated. They can see the client portals and everything (as the login logic is client side, they can just bypass that) but they won't see any sensitive data.

Is exposing the logic to the public like this safe? Can a hacker use this information to do anything at all?

Serverless applications bring with them a lot of benefits for application security, especially when it comes to securing the underlying platform, which is now the responsibility of the cloud provider. You don't have to worry about patching the underlying operating system, application server, and networking. However, serverless applications may still suffer from application layer weaknesses and vulnerabilities. I highly recommend reviewing the Serverless Security Top 10 guide, published by PureSec: https://www.puresec.io/sas-top-10-download

Proper disclosure - I am one of the authors of this whitepaper.


Is it valid to have more than 1  in a SAML Token response I am trying to provide compatibility between an existing SAML token system with JWT token schema. The current system generates SAML tokens with a structure as follows:

Is it even valid to have more than one in a SAML token and if yes what would be the JWT representation for the below

<?xml version="1.0" encoding="UTF-8"?>
<samlp:Response ID="aed9fa15c020fde" InResponseTo="acd3a67cb14a1d94" IssueInstant="2015-02-18T18:58:14.262Z" Version="2.0" xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol">
  <saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">......</saml:Issuer>
  <samlp:Status>
    <samlp:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success"/>
  </samlp:Status>
  <saml:Assertion ID="5d41027a4e2c2855" IssueInstant="2015-02-18T18:58:14.262Z" Version="2.0" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
    <saml:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity">......</saml:Issuer>
    <saml:Subject>
      <saml:NameID NameQualifier="USER" SPProvidedID="1047259662">ab_idl1</saml:NameID>
    </saml:Subject>
    <saml:Conditions NotBefore="2015-02-18T18:48:14.262Z" NotOnOrAfter="2015-06-20T18:58:14.262Z"/>
  </saml:Assertion>
  <saml:Assertion ID="5ea9fbba7ab940c0" IssueInstant="2015-02-18T18:58:14.262Z" Version="2.0" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">
    <saml:Issuer>APPID-b1713f46d4e1</saml:Issuer>
    <saml:Subject>
      <saml:NameID NameQualifier="USER" SPProvidedID="1047259662">user_name_app_name</saml:NameID>
    </saml:Subject>
    <saml:Conditions NotBefore="2015-02-18T18:48:14.262Z" NotOnOrAfter="2015-06-20T18:58:14.262Z"/>
    <saml:AttributeStatement>
      <saml:Attribute FriendlyName="user_id1" Name="user_id">
        <saml:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">user_name_app_name</saml:AttributeValue>
      </saml:Attribute>
    </saml:AttributeStatement>
  </saml:Assertion>
</samlp:Response>

According to section 4.1.4.2 of the spec, it's legitimate to have multiple assertions in a response.


What are the heuristic detection techniques most often used in modern AVs? Whenever I read books or academic papers and the subject of heuristic malware detection is brought up they always say the same thing: "it can be either static or dynamic", "it may use emulation", "may detect new malware, but higher chance of false-positives", and that's about the extent of how I've seen it described. What, specifically, are the techniques modern AVs use for heuristic detection?

According to Malwarebytes:

  ...if an application is programmed to remove important system files, the anti-malware software may flag it as malware (since applications should not be doing that). But, heuristic analysis can sometimes result in “false positives,” or programs flagged as malware that are actually legitimate.
  https://blog.malwarebytes.com/101/2015/12/how-does-anti-malware-work/

Most modern heuristic detection is a flag-and-score system. Basically each program scanned will get a score based on how shady it is, these scores are obtained by counting the amount of 'flags' a program gets. Flags are activities monitored and reported by the anti-virus when it attaches itself to a process. These are usually renegade activities such as modifying or deleting system files in the background, escalating privileges without user input, or downloading data from a remote server without displaying UI. After a scan is complete, these flag scores can be averaged to find how far away from normal some program's activity could be. After a certain threshold in the bell-curve, it is considered too mysterious to be normal and detected as a virus or PUP.

There are different approach between products, all with trade-offs, but all end in the same result:

System emulation, flag shady activity. (some malware can detect virtualization)
Scan binary, flag byte-marks associated with shady activity. (can give off false positives to similar less-shady logic)
Attach to running agent, flag shady activity in real-time. (debug-traps can halt detection)
Decomiple/reverse-engineer, flag shady code. (Code obfuscators can throw off results)


How to manage team passwords? How do most teams handle the storage of passwords, in particular the required changes when team members leave ?

Right now, we use a centrally stored encrypted file but the thought of changing 100's of passwords when key employees leave is a bit overwhelming.

One method I've seen used at larger companies is products like Cyber-Ark that essentially take control of the passwords for the boxes and then have a set-up where you can request a password for a specific host for a time period.  The application then gives you the password and changes it after the time period is up.  An additional advantage to this approach is that you have a log of who had access to the server and when.

That way when a team member leaves they won't actually know any of the passwords. Obviously you need to combine this with monitoring tools to stop people adding unauthorised accounts or back-doors but if you've got enough accounts to manage it can be a good approach.


Service TO Service Authentication & authorization I have two web services A and B the requests between those services is http.

I want so establish a secure connection between service A and service B to ensure the authorized and authenticate request from the source and insure data was not tampered.

My Application running on PHP "service B -the data store (the server)-".
My client is service from another side "service B -the client or service A-" and programming language we don't care about because we have HTTP Request.

If there are any server side implementation and concept can and body toll me I will appreciate.

I know SSL, but I am looking for something like OAuth protocol but simpler to implement

You can use the TLS/SSL protocol which can provide data confidentiality and data integrity. Combined with HTTP, this gives us HTTPS, which seems to be what you're looking for.


Banking card certificate Does anyone have an idea of what kind of public-key technologies are used in the bank perimeter ? Does banking card embedded x509 certificate ? OpenPGP ?

Perhaps a standard exists or a de-facto standard.

No, banks tend to use somewhat different technologies from the rest of the world. This doesn't necessarily mean that they use weak cryptography: banks tend to be good at risk management, and to put just enough money in security to make attacks rare without putting so much that security would cost more than the attacks that it would prevent. (As a customer of banks, the flaw in this approach is that it doesn't take account risk for the customer — that only enters the equation when banks are worried that some customers will be so unhappy that they'll change banks, which itself has a high cost for the customer.) For example, a lot of banking protocols still use 3DES when most of the rest of the world has standardized on AES.

The current standard used by major banking card providers is EMV. EMV uses some well-known building blocks: 3DES, SHA-1, RSA. This has been the standard protocol suite in Europe since the mid 2000s; a lot of other countries have migrated since then or are migrating. Many cards and terminals also support various legacy (often national) protocols for backward compatibility. Security is only as strong as the weakest link in the chain. Banks are pushing for EMV adoption by shifting liability for breaches to merchants when legacy protocols are used for a transaction, in order to convince merchants to renew their equipment to a newer generation that supports EMV.


How do I avoid the initial text portion when creating a PEM certificate with openssl? I've created my own CA with openssl. The problem I'm having is that when I sign a CSR and generate a PEM certificate with it, there is an initial text portion in the certificate where I was only want the actual encoded certificate itself.
In other words, the output certificate begins
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            9a:e2:f9:21:e1:fe:be:10:71:b0:1f:b9:7a:1b:ec:c8
        Signature Algorithm: sha256WithRSAEncryption

Where as I only want it to begin with:
-----BEGIN CERTIFICATE-----
MIIFGzCCAwOgAwIBAgIRAJri+SHh/r4QcbAfuXob7MgwDQYJKoZIhvcNAQELBQAw

Here is the command used:
openssl ca -config openssl.cnf -in  www.example.com.csr -out www.example.com.crt -batch -extensions x509

From my config:
[x509]
authorityKeyIdentifier  = keyid:always
basicConstraints        = critical,CA:false,pathlen:0
extendedKeyUsage        = serverAuth
keyUsage                = critical,keyCertSign,cRLSign,digitalSignature
subjectKeyIdentifier    = hash

I need to do this because the certificate is not being accepted by a certain application. When I test without the initial text portion it works fine.

This is not a programming or development question or problem and will probably be closed, but from the man page for ca(1ssl?) or maybe openssl-ca(1) on your system (unless Windows)  or on the web:

-notext
Don't output the text form of a certificate to the output file.

Although as commented it's also trivial to fix the file afterwards with standard text-handling tools; that's one of the many reasons PEM format is textual.


Chrome browser reports obsolete cipher (AES_256_CBC with HMAC-SHA1) Jboss 6 server is configured to support these ciphers:

TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384,
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA,
TLS_RSA_WITH_AES_256_CBC_SHA256,
TLS_RSA_WITH_AES_256_CBC_SHA,
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256,
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,
TLS_RSA_WITH_AES_128_CBC_SHA256,
TLS_RSA_WITH_AES_128_CBC_SHA

But the Chrome browser reports:

  The connection to this site uses a strong protocol (TLS 1.2), a strong
  key exchange (ECDHE_RSA), and an obsolete cipher (AES_256_CBC with
  HMAC-SHA1)

Should we remove all _SHA ones from the server configuration?

However, the nmap ssl scan shows, they are all A grade ciphers:

$ nmap -p 443 --script ssl-enum-ciphers.nse host-name

TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384 (secp160k1) - A
TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA (secp160k1) - A
TLS_RSA_WITH_AES_256_CBC_SHA256 (rsa 2048) - A
TLS_RSA_WITH_AES_256_CBC_SHA (rsa 2048) - A
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256 (secp160k1) - A
TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA (secp160k1) - A
TLS_RSA_WITH_AES_128_CBC_SHA256 (rsa 2048) - A
TLS_RSA_WITH_AES_128_CBC_SHA (rsa 2048) - A

The problem is not the SHA1 but the CBC. You need to offer an AEAD cipher like the GCM ciphers or   CHACHA20-POLY1305. From the Chromium (base for Chrome) projects documentation about cipher suites:

  To avoid this message, use TLS 1.2 and prioritize an ECDHE cipher suite with AES_128_GCM or CHACHA20_POLY1305. Most servers will wish to negotiate TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256.

You don't offer any of these ciphers so you get this warning. See also this answer for more details. See also the source code of Chromium, notable the function ObsoleteSSLStatusForCipherSuite in net/ssl/ssl_cipher_suite_names.c where this check is implemented.


How can I protect my website against bitsquatting? I've just read an article about bitsquatting (which refers to the registration of a domain name one bit different than a popular domain) and I'm concerned about how it could allow an attacker to load its own assets on my website.

For example, if my website located at https://www.example.org/ loads a script file located at https://www.example.org/script.js, then an attacker could register dxample.org and host a malicious JS file, which would be downloaded and executed by some users of my website.

Is there any standard defense technique against it?

Is there any standard defense technique against it?

As outlined in the other answers, bit errors when querying domain names may not be a realistic threat to your web application. But assuming they are, then Subresource Integrity (SRI) helps.

With SRI you're specifying a hash of the resource you're loading in an integrity attribute, like so:

<script src="http://www.example.org/script.js"
    integrity="sha256-DEC+zvj7g7TQNHduXs2G7b0IyOcJCTTBhRRzjoGi4Y4="
    crossorigin="anonymous">
</script>

From now on, it doesn't matter whether the script is fetched from a different domain due to a bit error (or modified by a MITM) because your browser will refuse to execute the script if the hash of its content doesn't match the integrity value. So when a bit error, or anything else, made the URL resolve to the attacker-controlled dxample.org instead, the only script they could successfully inject would be one matching the hash (that is, the script you intended to load anyway).

The main use case for SRI is fetching scripts and stylesheets from potentially untrusted CDNs, but it works on any scenario where you want to ensure that the  requested resource is unmodified.

Note that SRI is limited to script and link for now, but support for other  tags may come later:

  Note: A future revision of this specification is likely to include integrity support for all possible subresources, i.e., a, audio, embed, iframe, img, link, object, script, source, track, and video elements.

(From the specification)

(Also see this bug ticket)


OS X 10.6 and known unpatched vulnerabilities Apple is not renowned for publishing clear end-of-support announcements for their products.

In our network (a big university) we have strict policies and we do not allow unpatched systems. We were able to "forbid" Windows XP machines after Microsoft announced its end of support.

We would now like to do the same for OS X 10.6.

According to Wikipedia

  Unsupported as of February 25, 2014, though the last security update happened in September 2013 and an update to the Mac App Store on Snow Leopard was made in January 2016.

Sadly, Apple made a minor non-security update to the system in January 2016 because of the Apple Store giving the impression that the system is not dead.

Are there any known exploits for 10.6 that would allow me to show our community that the system indeed is not secure?

There have been several really big issues like heartbleed (probably only relevant to servers). Try to find some and see what you can do.

Then there is Safari. If users are smart, they install Chrome or Firefox to get updates. But Chrome doesn't support 10.6 anymore.

Anyway, if users use Safari, they are not safe. Think of TLS problems with old certificates.


In Healthcare IT, is a "break glass" mode to bypass access controls commonly required? I've seen referenced in literature the need to have a "break glass" mode in Healthcare IT applications.  In this mode, the access controls in an application can be bypassed for an emergency when it is critical for a user to gain access to imaging data.  Typically, the facility will have some sort of policy in place to justify using the mode after the fact.

I'm wondering if many facilities are demanding this feature in heathcare applications?  I don't recall seeing this in many real applications.

My healthcare organization uses Break The Glass with our EMR.  I work on the IT side of things so I'm not sure how it applies to the clinicians, but for us it is setup so that if we access any patient record we are required to Break The Glass.  In doing so we are forced to enter a comment as to why we need access to the record.

It's a good feature - with the introduction of the HITECH act, and of course with HIPAA, it is important to document why you went into a patient's chart.

As a patient, you have the right to request the names of all of the employees who accessed your medical record and you also have the right to know why they needed to see your chart.  By forcing the Break the Glass feature, we as employees are forced to create this documentation.  If we didn't have this documentation and a lawsuit was brought against my organization, the individuals who accessed the chart could be held liable if they cannot produce sufficient reason for entering the chart.

So in short, no it is not required, but it is an excellent way to mitigate risk - not only for your organization but for the individuals who can be held liable by HITECH and HIPAA.


Weird character sequence in email subject I've noticed that the subject in one of the spam emails looks like this in source:

Subject: Offe=?UTF-8?Q?=EF=BB=BF?=r fr=?UTF-8?Q?=EF=BB=BF?=om C=?UTF-8?Q?=EF=BB=BF?=redi=?UTF-8?Q?=EF=BB=BF?=t On=?UTF-8?Q?=EF=BB=BF?=e Ba=?UTF-8?Q?=EF=BB=BF?=nk=?UTF-8?Q?=EF=BB=BF?==?UTF-8?Q?=EF=BB=BF?=

but in web it looks normal

Offer from Credit One Bank

The only thing I recognize is 0xEF, 0xBB, 0xBF, which is the UTF-8 BOM.

Which interpreter recognizes this character sequence =?UTF-8?Q?=EF=BB=BF?= ?

Is there a vulnerability around email subjects? What are they trying to do?

Ah, the character sequence is legitimately used to encode UTF-8 characters in internet headers, since they can contain only ASCII (rfc1342). Here however, is used to hide from spam filters, as Ghedipunk said in a comment.


What knowledge is neccessary to work in computer security? What level of knowledge does a person need to work in computer security?  Are the following skills sufficient?

Good knowledge in TCP/IP networking
Good knowledge in firewalls/firewall techniques
Basic knowledge in programming
Basic knowledge of security protocols (RSA, symmetric keys etc.)
Basic knowledge of cryptography (theoretical understanding)
Good knowledge in operating systems (win/unix)

Is that a sufficient skill set?  Are there any additional areas that would need to be understood?  Would more knowledge be needed in any of those areas?

Best regards,

It really depends on what you want to do in computer security.  To be a generalist, you are going to want to put more time in to getting a solid understanding of the principals of cryptography, if not the exact algorithms.  Without this, it would be kind of like a carpenter that doesn't know what different wood working tools are used for.  They wouldn't know when to pick which tool.  Number 4 and 5 are really the same thing I think.  You can't have a good understanding of how cryptography works practically (the limitations and strengths) without also understanding the theory behind it at a similar level, at least in my experience.

Good is also a rather nebulous term since it could have any number of meanings.  Certainly it would be beneficial (probably critical) to know enough to hold a coherent conversation with a specialist in each of the particular fields.


Why AdES -A signatures require TWO timestamps? Latest ETSI standard CAdES, XAdES and PAdES require for baseline profile LTA  to fulfill previous LT, T  and B levels. Summarizing,the conformance requirements are:

B : Base signature with content-type, signing-time and signing-certificate
T: Signature timestamp
LT: Certificate and revocation values
LTA: Archive timestamp

More or less are simplifications over the previous BES, EPES, T, XL, and A levels, where the requirement is also present

Applying a timestamp is an expensive process in time and money, because it is usually performed by an external trusted CA

Question: What is the reason for applying two time stamps when building an LTA directly, bearing in mind that the last time stamp protects all content? Why -T timestamp is not optional?

As you said, the second timestamp protects all content.
It is there to specify that the revocation data was valid at a certain time, due to the archiving part of this type of signature.
If the revocation values were present without the second timestamp, there would be no way to prove their validity at the time of the signature.

Using CADES-A, the first timestamp theorically could be removed, but as you show it, CADES-A is over CADES-C, which is over CADES-BES. The standards are over each other and each type of signature has to match the standard. For example, CADES-LTA (Long Time Archiving) would be over CADES-A, etc.


ettercap filters - drop the packet and inject packet if (ip.proto == TCP) {
    if (tcp.src == 2404 || tcp.dst == 2404) {
        if (DATA.data+6 == 0x64 && DATA.data+8 == 0x07) {
            msg(" pos activation - drop \n");
            drop();
            inject("./fake_pkt");
        }
    }
}

We're able to successfully drop and inject packet using the ettercap filter above.

fake_pkt file content is "\x68\x04\x07\x00\x00\x00".

The injected content size is 24 characters and the injected packet contents are "\x68\x04\x07\x00\x00\x00", as text.

But our goal is to send a binary packet (68,04,07,00,00,00) of the size equal to 6 bytes.

May I know how to write hex values into the fake_pkt file to achieve our goal?

inject() inserts the contents of a file as is. You need to create a binary file, 6 bytes long, and inject that. There are plenty ways to do that, one of the simplest is to use Python:

python3 -c "
with open('./fake_pkt', 'wb') as pkt:
    pkt.write(bytearray([0x68, 0x4, 0x7, 0x0, 0x0, 0x0]))"


what fields should I encrypt in a database containing user information? So in a database many user fields could exist. Normally when I setup a database I go off of the security experts recommendations on what fields to encrypt, but I'm curious what is the most standard set of fields to encrypt? As far as I've seen it's usually the password(hashed), credit card(AES), and the phone number(AES), but the address, name, and other parts are left plaintext.

Since a lot of people here probably encrypt other fields as well, I'm curious what fields do you encrypt in your user databases?

Encryption is just a tool; it is applied for mostly three reasons:

To achieve some confidentiality. This makes sense in contexts where the stored data (database contents) could be exposed to malicious third-parties, but some specific data element (the encryption key) could be kept hidden from the same malicious third-parties.
To achieve compliance to some regulations. For instance, when dealing with credit card information, one more-or-less has to follow the prescriptions of PCI-DSS, including applying some encryption for some pieces of data.
To give a feeling of security by sprinkling some crypto all over the place. This reason, of course, is not good; however, it is very common in practice.

For the first reason, this makes sense only relatively to an attack model where attackers cannot read the encryption key. The application which accesses the database must, by definition, be able to read the data contents, so it must know the decryption key. Consider, for instance, a comprehensive full-database encryption (what Microsoft and Oracle call TDE): this encrypts all the database contents; but the application that accesses the database must know the key, to decrypt the data on-the-fly, and sees the cleartext contents. If the attack model is about attackers who steal backup tapes or recover discarded hard disks, then TDE is the way to go: such an attacker will only see a big encrypted pile of data, with a key that he does not have. On the other hand, if the attack model is about SQL injections, then TDE offers no additional security since the injected SQL is interpreted in the context of the normal application, over the decrypted data.

For the second reason, encrypt that which is necessary to achieve compliance, and be done with it. That's the good thing about compliance: you do not have to think, only to follow the rules.

For the third reason, you need to invoke the crypto gods for every field that auditors / bosses / customers feel to be "important". Usually, people feel nervous about what they consider to be their identity, so names, email addresses, street addresses, phone numbers... should all be encrypted. Since this is only security theatre, you can most of the time achieve the same kind of psychological effect with an "encoding" that needs not be encryption properly said (e.g. Base64).


How do I prevent someone from using my certificate to sign a malicious script on my PC? The first step to make Powershell more secure is to create a certificate to sign my scripts. Then you actually sign it with this command:

Set-AuthenticodeSignature -FilePath myScript.ps1 -Certificate (Get-ChildItem -Path Cert:\CurrentUser\My\ -CodeSigningCert)

What creates a bit of a headache for me, is that you don't even need to specify the name of the certificate, it is chosen automatically.

Let's say somehow the password of the user owning that certificate get's leaked or a program somehow gains entry into that account. How do I prevent someone from using PowerShell to just sign their own, malicious script, to attack my infrastructure?

For example, by executing this on the command shell:

powershell /command Set-AuthenticodeSignature -FilePath .\myScript.ps1 -Certificate (Get-ChildItem -Path Cert:\CurrentUser\My\ -CodeSigningCert)

I have also studied the New-SelfSignedCertificate command and I do not find any indication that the certificate itself can be protected by a password or similar mechanics. What am I overlooking here?

Aside: requiring the cert (and key) name wouldn't be any more secure, because those names aren't secret. Also even if your policy calls for signing, if the malware is executing on your system so that it could sign scripts it can also change the policy and run without signing. What signing prevents is tampering or forgery when you copy scripts from one system to another as data, like via a net share, website, email, or document. IME best practice is to do code signing (which scripts are) on separate machines with the highest defenses possible -- no browser, no email, maybe even no network connection (aka 'air gap'), and key in hardware (see below).

Yes, certs and (more important) keys in the normal Windows cert store(s) can be accessed without a password. If you use a smartcard or similar hardware module instead, it might require a PIN on each use; I don't have one myself and am not up-to-date on how modern Windows handles them. Plus this would give you the ability/option to remove the smartcard from the machine and physically protect it, like in a safe or such.

What would definitely require a password on each use is to keep the cert and key in a PFX file (aka PKCS12). https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-authenticodesignature?view=powershell-6 gives an example of doing that. New-SelfSignedCertificate apparently can only write to the normal store or a smartcard, but it looks like you could Export-PfxCertificate to a file and then delete from the store. (I haven't tested, though.)


What kind of certificate should I get If I want to secure a connection between a web server and a database? I know people buy SSL certificates to secure their sites. What kind of certificate should I get if I want to encrypt a connection between an application server and a database? Application server may not be accessible through a public url, by the way.
My question is general, but the real situation is Windows environment on both servers and RavenDb as a database, if that matters

Note: I control both servers and their security settings.

It is important to understand that certificates provide integrity and encryption provides confidentiality. In other words; the certificate makes sure that you are talking to who you think you are (if part of chain of trust), but it does not encrypt your connection. However integrity and confidentiality nearly always go hand-in-hand, which is why the public key of a client is contained within its certificate. Once the identity of the asset serving the certificate is verified, its public key can be used to encrypt the connection and negotiate further encryption details.

In theory it would suffice to simply generate a keypair on both the database server and application server, and use those to configure the encryption between the two. The fact is that many systems require certificates to encrypt the connection, so as said, also the identity of the other side of the connection can be verified. Since your application is not publicly facing, the certificate does not need to be signed by a CA. You would just need to generate a keypair, create a CSR out of it, and consequently self-sign it. No money has to be spent here.

You can use these self-signed certificates to configure the encryption between the database and your application.


reaver - [!] WARNING: Failed to associate with xx:xx:xx:xx:xx:xx (ESSID: (null)) I am familiar with dict-password cracking but I recently moved on to reaver. When I run reaver, it pops up with an error [!] WARNING: Failed to associate with xx:xx:xx:xx:xx:xx (ESSID: (null)).

I searched for some methods to solve it, but every time it was the same. Yes, I did set my interface to monitor mode. Can someone help me?

Things I tried:

  $reaver -b xx:xx:xx:xx:xx:xx -i mon0
  $reaver -i mon0 -b xx:xx:xx:xx:xx:xx -vv -d 0
  $reaver -b xx:xx:xx:xx:xx:xx -i mon0 --d-small
  $reaver -i mon0 -b xx:xx:xx:xx:xx:xx -vv --dh-small
  $reaver -i mon0 -b xx:xx:xx:xx:xx:xx -c 48 -f -a -w -vv -K 1
  $reaver -i mon0 -b xx:xx:xx:xx:xx:xx -vv
  $reaver -i mon0 -b xx:xx:xx:xx:xx:xx -c 48 -f -a -w -vv
  $reaver -i mon0 -b xx:xx:xx:xx:xx:xx -c 48 -vv
  $reaver -i mon0 -b xx:xx:xx:xx:xx:xx -v --lock-delay 610 -d 0 -c 48
  $reaver -i mon0 -b xx:xx:xx:xx:xx:xx -v -d 0 -c 48

(xx:xx:xx:xx:xx:xx = ESSID)

To associate to an AP with reaver you must have a good signal. That's the first important point. And sometimes depending of your Chipset could not be possible. For example, if you have (like me) an Alfa Networks usb device with chipset Ralink RT3070 you can't use reaver. Simply is not compatible. Ralink chipsets doesn't work with reaver. For that chipset you must use bully which is a "cousin of reaver" :D

What I want to say is that there are a lot of factors... and one very important is the chipset. The tight solution is to handle both softwares "reaver" and "bully" and test everything with both.

As a personal suggestion, I can recommend to you to use a very easy to use bash script which automatize all of these tasks called airgeddon. The script can do a lot of things more... but it has a WPS menu for testing all of this using reaver and bully. Give it a try.


How can a website block IPs behind a NAT? Will a website be able to block my IP address alone somehow, while I am running a security tool behind my NAT? Or will it block my ISPs gateway IP?

Since you are behind a NAT, your local IP is translated by the gateway. So a server/website will get a traffic from your ISP IP, and if they decide to block an IP, it will be of your ISPs. There is no way to block your local IP on a server side.


Exploit development - Will different devices with the same OS/Architecture have the same exact process memory (e.g. addresses) for a given binary? Sometimes, when I develop an exploit that perfectly works on a given machine, it will fail on a different one, despite them having the same OS/Architecture and configurations (like language, which in my experience can have some effects on the process memory, at least on Windows).

I am aware of the fact that techniques exist to achieve more reliability in some cases. Still, I wonder if an exploit developed and tested on a given device (let's say a Google Pixel), with or without using these techniques, is supposed to work on another (like a Samsung Galaxy S8).

If not, why? Shouldn't the same binary have the same process memory? I can think of different cases in which this shouldn't be true, for example if the program loads data that are device-specific. But when it isn't the case, will the same binary, feeded with the same input, behave differently when ran on different devices?

This questions assumes that ASLR is disabled.

EDIT: I am asking about exploiting memory corruption vulnerabilities - like use-after-frees and OOB reads.

Heap layout is a fickle thing. Real-life examples from the windows world:

Non-english versions of program load additional internationalization DLL at fixed address in middle of heap.
different allocation patterns between starting program on commandline (as your fuzzer/debugger does) and user opens document with "file"-"open".
Security product loads %$§#-ton of DLLs into all processes that all start threads & allocate stuff on the heap. I guess they prevent exploits by not leaving any free memory for them.
Windows XP brought all new heap allocation strategy with a service pack. Was it SP2?
Browsers have complicated heuristics for when they precompile & jit, how much they jit, when they free jitted code, etc. Those heuristics also look at total availaible system memory. Same goes for garbage collection.

Never assume too much about your heap layout.


In house mitigation for a volumetric DDoS attack Can a volumetric DDoS attack be mitigated by some in house defense or does the defense always need to be on the cloud? If yes, then why?

It depends a bit on what you consider "in house". You cannot filter volumetric attacks once they're on your network, since your external link(s) are saturated.  So the filtering has to be done before traffic hits your external link(s), for example by your upstream provider(s) or by some dedicated scrubbing service. This can either be blackholing (discarding all traffic to the target), or scrubbing (dropping unwanted traffic while letting valid traffic pass).

If your network is running BGP, the triggers for deciding to do this can often be coming from your network, for example by using a remotely triggered blackhole, which uses a BGP session to indicate to a BGP upstream that traffic to a specific target should be discarded, or by injecting more specific BGP routes which divert the prefix which contains the IP address which is under attack via a scrubbing center.

If your network isn't running BGP (but uses an upstream provider for this), an upstream provider may provide blackholing or scrubbing services, either automated (based on anomaly detection) via a customer portal or after contacting them.


"ScriptResource.axd" vulnerability in Windows Server 2008 I am using Windows Server 2008, Plesk 9.5, IIS 7, SQL Server 2008, and recently I have received and email claiming this server is vulnerable, and sent me the following URL:

/scriptresource.axd?d=QivxuR3S70uO2-sZID2TL45AtoGwC4WTODQ6W4h3ca0AAAAAAAAAAAAAAAAAAAAA0

Using this URL on any website that I hosted on the server, I could see the web.config file. I would like to know whether this indeed is a vulnerability, and if so, how to mitigate it?

Sounds like that's the padding oracle attack that came out in 2010.  You should check your server for the appropriate MS patch (MS10-070).

There's more information on the attack here


Digitally sign all the packets from client machine If I insist on digitally signing all outgoing packets from my computer, would it affect my browsing experience?
I mean if a website doesn't expect me to sign my packets, and still I sign them, can I access that website?
As the packet data is in plain text and only its hash is encrypted and attached with the data, I think the website should be ok with that. But I am not sure.

Thanks!

If you try to force SSL/TLS - even without encryption - on websites and services that are not configured to use it, you will find that most of the Internet will be broken for you. For SSL/TLS to work, both ends of the connection must support it. Otherwise the connection negotiation will fail and your computer will treat the website as if it doesn't exist.

Besides that, the most basic problem with this idea is that it adds network and system overhead for absolutely zero security benefit. Digital signatures are only worth having if they're actually going to be verified. If a website is going to verify your signatures, it will be configured to support SSL/TLS. If SSL/TLS is not supported, there is no point in signing.


Laptop had a NSFW page open when I got to work, cause for concern? I use my personal lap top for work. The other day I took it in an opened it, logged in and there was a NSFW page open from when I last used it at home. I immediately closed the (incognito) page, no clicks or further browsing. Will that have been captured as I was logged into the wifi?

It depends on several factors.

If you restored the PC from sleep/slumber/hibernation, then what you saw was the PC state before sleep, not something that had just been downloaded. No traffic was generated, nothing could possibly have been logged.

But the page might have had some active content that was accessing the network. If so, upon restore it might have tried accessing again the network, and that traffic might have been logged. On the other hand this is not so likely, and however this kind of traffic is not NSFW per se - even if it might go out to something like nastysexyserver.com.

If you had just opened the browser, though - if the "logged in" means that you had booted the OS, not restored it from sleep - then things get hairy (pun possibly intended), because the page might have come from the PC's cache or could have triggered a (partial) reload.

I know for a fact that the latest Firefox reloads the tabs when re-opening; but I do have the "save tabs at shutdown" setting checked.

Also, it depends whether the page was HTTP or HTTPS. If the latter, then the URL may have been logged, but not the contents. Most analysis software would discount this as a false positive (typically triggered by an ad on an unrelated page).


XSS payload without html tags Which payload can be used to exploit XSS without using html tags <>. These tags are filtered(sanitized) and encoded in output.

This might not prove successful but perhaps you can try something like the following as it does not use the specific tags (<>) you are referring to:

Set.constructor`alert\x28document.domain\x29```

This was found from the below OWASP source for attempting XSS by filter evasion techniques

Source:
https://www.owasp.org/index.php/XSS_Filter_Evasion_Cheat_Sheet


How can I encrypt something user provided without risk of the key being exposed? So, let's say I have a theoretical service. User has some text they want to encrypt. They pass it to me, and I encrypt it. Then, only I should be able to decrypt it afterwards. Another kicker, it must use a common key. The key can change occasionally, but not be user-specific or anything like that.

What can I do to avoid people analyzing the encrypted results of known text to find the key? I know there are things like Length Extension Attacks. What encryption algorithm would be safest?

If an encryption algorithm is susceptible to known plain text attacks, then it is fairly severely broken.  Is there a reason that you don't use a public/private key encryption scheme?  Then the user could actually encrypt it prior to transmission and you would still be the only one who could decrypt it.  More ideally, you'd really want to have them choose a key, encrypt the data (symmetrically) with the key, encrypt the key with your public key, send the encrypted data and encrypted key to you, then if you need to use a common key, you could decrypt the data and re-encrypt it with your own key.  This would give you protection while the file is in transit.  (Alternatly, if it is a web service, simply using SSL for the transfer will do the same thing.)

Is there a particular reason you need to use the same key for every user?  This is a big point of insecurity as it results in a single point of failure.


Override parent .htaccess with php.ini? Is it possible to override parent folder .htaccess rules with child php.ini or some other file except .htaccess?
What I have is:

/var/www/site/static/.htaccess
/var/www/site/static/abc/
/var/www/site/static/abc/def/(I have access to this)

I have access to def folder in above structure, can I override parent .htaccess rules which blocks all executable files like php, pl, py, asp, etc? How can I enable rules to execute php files in this directory without creating .htaccess?

Yes, you can override parent .htaccess with a .htaccess file of your own. You can execute php/etc from within the .htaccess file itself. Take a look at my htshells project for some examples: https://github.com/wireghoul/htshells/


Does authentication provider have access to site? If I use Facebook or Google as authentication providers, do they gain access to the data in my website? Can they scrape it with a bot? Can I prevent them from gaining this access?

Let's unpack this into the specific questions. I'll try to be brief in my answers because the overall theme should give you an idea what the situation is...

  do they gain access to the data in my website?

Assuming the data is protected by access controls - and not already public - then it would be a violation of your trust in the third-party authorization provider for them to access your site's data directly. They are unlikely to do this, because the value of stealing your data would not be worthwhile given the lost value if they lose your trust.

But technically speaking, there's nothing in the OAuth protocol that would stop a provider from spoofing your user's identity. By using a third-party provider, both you and your users are placing your trust in them not to do this.

  Can they scrape it with a bot?

Given that they could spoof a user, they could presumably gain access to your site by performing an OAuth handshake. If it were authenticated and understand your authentication scheme (ie. you're using an auth cookie, or the bot knows how to use your Bearer Token scheme or similar), they could theoretically browse the authenticated portion of your site to scrape it.

But as mentioned above, they probably wouldn't. Again, this is the risk you take by using a third-party provider. You need to trust them.

  Can I prevent them from gaining this access?

Not really. If you're just worried about automated access, you could do something to obscure the authentication between the client and server so that a web scraper wouldn't likely know how to use the auth token. For example, you might change the header name. That said... this is probably a bad idea. There are a number of assumptions made by web servers and server monitoring tools that would help to keep from leaking Authorization headers, which might not be true for other headers.

All said and done, if you're going to use a third-party authorization provider, you need to trust that they will have appropriate safeguards on their end to protect your application from misuse. If placing this trust on the third-party is not appropriate for your level of risk acceptance, then don't use a third-party identity provider.


Can we predict the technology used from the URL? As a person who is learning pentesting, I want to know if it is possible to predict the underlying technology used for the developement of the site from the URL?

For example:  This is the URL of the site

https://www.somesite.com/cgi-bin/bv60.dll/somesite/services/history.do?click=true&LinkValue=2&BV_SessionID=@@@@1169531050.1338361729@@@@&BV_EngineID=ccdeadfglgghiigcefecehidfgmdfil.0&canhistory=3&voucher=5

What does the cgi-bin & bv60.dll & BV_EngineID tell us?

In information gathering every piece of information is valuable but how come we usually don't consider URL the key information for predicting. I never read any chapter (from any book) on the knowledge from URLs

There are many books that talk about using this type of info gathering and vulnerability testing, but it is under the heading of 'HTTP Headers'. Because web servers are usually configured to 'prettify' URLs, much of the info you list is usually contained in the header of the http request.

For the specifics of your question:

cgi-bin means they use cgi scripts
bv60.dll means they are likely using Windows as the server
BV_EngineID is an internal variable and not helpful unless you can track that variable to a certain known application

But, all of this information can be 'faked' by the server, and all this info and more can be discovered using web server scanners and passive analyzers.

So, it is important to use URLs for info gathering, but anything found needs to be verified, and there are better ways to discover the relevant information.


Is suggesting a correct url in a 404 page bad practice? I'm currently writing a web application, and my client asked me if it would be possible to suggest a valid URL to the user when they accidentally write a typo in the URL bar, an example of this would go like this:

  Bob navigates to 'https://www.example.com/product'
  The web server is unable to find the route '/product', but knows that the route '/products' does exist
  The web server suggests Bob to navigate to '/products' instead
  Bob navigates to '/products' and continues browing the website

This example would cause Bob to have a better user experience.

However, it led me to wonder if this is considered bad practice, as the server might expose URL's the admin of the website might not want to show publicly.

If Bob is trying to type products and mistypes product, he already knows there's a URL in the website for products and so you're not telling him anything he doesn't know. If you don't suggest URLs that shouldn't be public, you won't have any issues.
Why use a 404 message though, and not do an immediate redirect?


Secure private keys in unattended servers Suppose I have a server (e.g. an internet connected raspberry pi) that needs to autonomously access some third party service (e.g. stripe, aws, etc.). To use this third party service via their SDK, I need to provide it with a secret key in order to initialize the SDK. My question is, how do I store this secret key in the server securely?

I don't want to store the key in plaintext, but encrypting it seems like it wouldn't help. If it is encrypted, I then have to provide some sort of credentials that the server can use to unencrypt the keys. Then these credentials are on the server, and getting access to those lets you unencrypt the key anyways so nothing changes.

I feel like encrypting keys and then providing the decryption password is like putting valuables inside nested shoeboxes and saying "HA! They will never be able to get to the inner shoe box because they have to open the outer one first!"

What is the best practice here?

Let's start with the constraints:

You need some kind of shared secret to send to a service to authenticate, so you need to be able to access the plaintext.
This needs to be done in an automated fashion (unattended).
You'd like to protect the credentials as much as possible.

First, we have to acknowledge that it is impossible to completely protect them, and it may or may not be worth doing so.  If someone can execute code on your server, they can do almost anything the legitimate service can -- including reading the keys and using the keys to make requests to remote services.  Depending on how much inconvenience you're willing to suffer, however, you can make them harder to use.

First, let's start with the "best practices" that have little to no impact on the ability to use these.

Run each service on your server as a separate user.  Ideally, add a MAC system like SELinux or AppArmor to further contain a compromise.
Store keys/secrets in files that are only readable by the proper service and lock down the permissions as much as possible.  (0400 on Linux.)
Ensure that the keys provide as little access as necessary on the remote end.  Uploading files to an S3 bucket?  Create an Access Token with only that permission.  (This way, if compromised, it limits the damage an attacker can do.)

If you need to go beyond this point, you can do a few things:

Store the secrets in a hardware module.  (Particularly if asymmetric crypto is an option.)  This won't prevent an attacker from using your credentials, but will prevent them from exfiltrating them.
Use a hardware module that requires human interaction.  When the service starts, you'll need to enter a PIN, and then the service keeps the decrypted key in memory only.  (Of course, a good attacker can probably get the key out of memory, but it raises the bar.)

Beyond this point, we get into the "silly for most applications": air gapping, interactive tokens requiring PINs for each signature, etc.  The unattended nature will quickly go away.


Strange Log in Apache I found in my Apache log something strange in requested URL / method request (I suspect an attempt to hack):

\x1b\x95J\xe2h\xa7\xcfj\xe1`\x85R\x1f\x98\x9e\xcf\xdedFM(\xa8\xbcc\xc0P\xd9::e\xed\xaa~L\x88\x19\xca

full log line:

localhost:80 [REDACTED IP] - - [05/Nov/2015:11:04:05 +0100] "\x1b\x95J\xe2h\xa7\xcfj\xe1`\x85R\x1f\x98\x9e\xcf\xdedFM(\xa8\xbcc\xc0P\xd9::e\xed\xaa~L\x88\x19\xca \xbfs\x7f " 400 226 "-" "-"

localhost:80 [REDACTED IP] - - [05/Nov/2015:07:04:14 +0100] "{\xd8\xc7/ \xef\x02\xbc9~\xdb" 400 226 "-" "-"

I already saw this kind of code in PHP code to force something like recompiled code to be executed or something like that, it stays obscure in my mind.

What is this code (language)?
Can I translate it ?
Any global info that would help me to understand...

In that field where you see the "strange code" is where you see the HTTP request that was made to the server, for example "GET / HTTP/1.1".

That log line means that someone connected to your server and send that "strange code" instead of a normal HTTP request, it could be a exploit for your current server or trying to exploit the shellshock bug.

A good thing to do now is try to check if there are some known bugs for your current Apache version, and test your system agains shellshock exploit.

How to reproduce it: printf "\x1b\x95J\xe2h\xa7\xcfj\xe1`\x85R\x1f\x98\x9e\xcf\xdedFM(\xa8\xbcc\xc0P\xd9::e\xed\xaa~L\x88\x19\xca \xbfs\x7f " | nc -n -i 1 www.website.com 80
How to get the converted code: printf "\x1b\x95J\xe2h\xa7\xcfj\xe1`\x85R\x1f\x98\x9e\xcf\xdedFM(\xa8\xbcc\xc0P\xd9::e\xed\xaa~L\x88\x19\xca \xbfs\x7f "