Is it possible to block specific users that connect to the internet behind of same gateway with NAT? Assume there are two internet users (A and B) that connect to the internet from the same gateway by using NAT. That means they use same IP address while passing through our firewall. Now assume we detect illegal traffic (such as DDoS) from this gateway and the attacker is user A.

In this case, is it possible to block only user A so that innocent user B can continue to connect to servers behind our firewall? Surely we can not achieve this by IP blocking. If possible, which options do I have to do that?

To clarify, I added a network topology.

In the general case, no.

In some specific cases, you can.  For example, if you're running a webserver and the gateway's NAT modifies HTTP requests to include an "X-Forwarded-For" header, you can use the XFF header to distinguish and block individual computers (assuming, of course, that the gateway is honest).


Searching encrypted storage I have been reading some very interesting academic papers regarding the ability to search encrypted data without needing to actually decrypt the data.  Doesn't this defeat the purpose of encryption in the first place?  I can imagine language-specific "brute force" attacks in which I re-assemble the plain text from the encrypted text simply by searching for "interesting" combinations of words.

What is the current practical state of the art in searching encrypted storage and why do we want it?  What problem does it actually solve, or are the problems entirely manufactured due to other current environmental conditions (eg. searching sensitive information on the "cloud")?

The "safe" versions of searching in encrypted data assume at least one of the following:

the pattern to search for is also encrypted with the same key (or some kind of related key) than the data itself;
the search result ("pattern was found there") is encrypted with the same key (or some kind of related key) than the data itself.

With either of these properties, the search engine does not leak information on the data to someone who would not be able to decrypt it in the first place.

The ultimate goal is to be able to offload the grunt work of searching to a big cloud system, while not needing to trust that system. Fully homomorphic encryption is the generic full-blown solution for offloading any kind of work, and the best currently known solutions for that are utterly unreasonable to apply because the overhead is tremendous (it can be implemented, but there is little use in offloading work to a cloud if the result is something slower than a pocket calculator). Encrypted data searching is a specialization: by restricting ourselves to a specific kind of work to offload (i.e. searching), we hope to find algorithms which are sufficiently lightweight to have a practical application.

To my knowledge, the field has not produced anything practical yet (but there is no intrinsic reason why it could not).


Using Fiddler to capture few important Details I want to implement the following requirement.

In an online Bank Transaction, a User wants to send an amount of $1000 to an Account A. I want to see that the request is going unmodified to Banking Server. So, I am using a Proxy Server as Fiddler n Client Side where the user enters Account and Amount information. Upon clicking submit, the proxy will reconfirm the Account and amount details before it sends to Server. So, I want to achieve this using Fiddler on client side. Is it possible with Fiddler? Or Is there any better Proxy that can do what I want? kindly let me know.

Thanks,

Fiddler would be the right choice for a client-based proxy implementation I guess, and it can be used as a stand-alone application or embarked in your application code (the user browser in your case).

However, if you want to do this as a protection measure, you should consider this as weak as a javascript control. Everything running on client-side can be tamperred and Fiddler is no exception to that.


Is dual control password is a feasible way to secure against unauthorized login? I see that some organizations practice dual control password especially when it comes to critical system logins, etc. Is it feasible to implement such policy considering certain trade off such as increased resolve time for critical production issue and increased complexity in password management?

Well, by definition if some organisations are doing it, it must be feasible!

More generally, all security controls have a cost and when you select a control the cost must be taken into account. Is it worth it? If so, implement it. If not, don't.

Dual password control is a very powerful and effective control against loss of integrity; but as you point out it comes with a high cost in terms of systems complexity.

That's why it's pretty rare to see it used, but if the integrity of the data is important enough, that cost is worth paying. The classic example of dual control is the launch controls for a nuclear missile. If the possible impact of a failure includes the end of the world, it's hard to argue that the controls cost too much!


sql injection mitigation by signed db entries? In a php/mysql based system I work on, they recently found several SQL injection vulnerabilities. Those come from 3rd party plugins, and I must assume there are more to be discovered.
My major concern is elevation of privileges, as almost all data except user data and credentials come from external systems and are overwritten every few minutes.
With the understanding that this would tackle elevation scenarios only, and that there are many other strategies that should also be followed, please provide feedback if this mitigation strategy would work:

Create a passphrase in a config file, let's call it "admin-salt".
Normal users log-in by providing a password, that is then  hashed with a db-stored per-user-random salt and compared to the hash in the db. Admin users on the other hand log in by providing a password, that is hashed both with the random user-salt and the aforementioned admin-salt.

Therefore, to create a new admin user, elevate a user or change an admin users password, the database.users.passwordhash field must be filled  with knowledge of the secret admin-salt. This happens programatticly if the user is created or elevated via backend and by an authenticated admin, while an sql injection leaves an admin user with an incorrect password hash.
Additional question: In case that's a viable approach and I didn't miss something obvious, why is it not more common practice?

Yes sounds reasonable. Especially to put salt and pepper in different parts of database and code.
But do not forget:
If the attacker has access to the web server, he can read out all described things using the code and, if necessary, adjust them to his needs. He can determine the algorithms used and use the found hashes to create a customized dictionary attack using a wordlist and the  algorithms on the server.
If SQLi already exists and database and code are on the same system, this can mean:

That the code is read out
Executable code can be uploaded and executed to gain access to the server

A good example of this offers
https://www.youtube.com/watch?v=oI_ZhFCS3AQ
So probably you want to double-check that the 3rd party sqli's found are not accessable from outside.


Can a bug in an application that has no internet connection be used from outside I have recently been occupied with a question regarding IT security. Suppose there is an application on a PC that is connected to the Internet, but it does not have access to the Internet or support any other connection (such as Bluetooth or NFC).

Can an bug in this software be used from outside to gain access to the system?

Personally, I don't think that is possible because the application has no external interfaces. Is that right?

Directly? No. By your scenario's definition, the "bug" is local to the computer and not a matter of a bug in its networking or communications (because it doesn't have that function).

But if the computer is accessible by other means, then once access is gained, the bug can be exploited. That's why it is still very important to update applications even if they do not have network access.

It is a common scenario that an attacker gains partial network access to a computer through some bug in some other application or a misconfiguration, or by tricking the user to run malware. And while that access is limited, it grants access to another vulnerable local application that the attacker leverages to get deeper access, and depending on the bug, and in a worst-case scenario, full control over the computer.


Setting a domain in Veil-Evasion for payload Can we set a domian, i.e., abccorp.com instead of the IP when we use set LHOST in Veil-Evasion? Is there anyway to do it?

Thanks

Just lookup the IP behind the web server with a DNS lookup. There are plenty of sites that can do this, such as: site24x7.com/find-ip-address-of-web-site.html.

Also, I have to assume you don't know what DNS is. DNS or domain name service is a way for routers/service providers to give friendly names for servers that people want to connect to. For example, instead of typing in the IP address for google, you type in google.com, and a DNS service finds the IP address of the site with that domain name so you don' t have to memorize a long chain of numbers for every site you visit.


Malwarebytes found bitcoin miners after I installed a new drive. Is my system screwed? Recently I bought this external hard drive from Amazon ("Sold by: Amazon.com Services, Inc").

The first time I plug it into my computer, Malwarebytes shows this report (it found bitcoin miners in my Downloads directory):

D: is my existing drive and the Downloads directory is my default downloads folder.

Is my system screwed?

From the report, it seems your antivirus stopped the programs before it could have done anything. I would just flash the hard drive and use it or return it and get a new one. As for why it was there I'm guessing someone purchased the hard drive and put the files there then returned it hoping someone would install it by mistake.

PS: As a safety measure I would scan the whole PC with the antivirus.


What are the tools/frameworks/techniques for authorizing a device accessing a web app? I've a password protected web application (ASP.NET 4.5), and a requirement that when a registered user accesses the site from a device for the first time, I should authorize that access by sending an authorization code to user's email, and validating that s/he can provide the correct code back.

It's not mandatory, but considered nice if user does not have to authorize the device when s/he accesses the site using two different browsers on the same machine.

Once device is authorized, system must not prompt user for an authorization until some period is expired, say a month.

Solution must also be tolerant towards for dynamic IP community, and should not keep prompting for authorization, just because the IP visible to outside world changed.

Here is how my current solution works, but apparently it has some weaknesses.

I primarily depend on the user's IP address to detect if this is a new device (Did not use User Agent string, as they seem to change when browsers update).

When a request comes in, I check if there is a cookie indicating that device is authorized by this user already, if so request may proceed.
If a cookie is not present, I check in local db to see if there is an authorization obtained for this IP by the user, by correctly entering an emailed code.
If authorization record is found, in order to remember authorization for this device (and not to prompt again if IP changes), I create a cookie in client's browser, set to expire in a month, or whatever time left on that obtained authorization.
If neither a cookie, nor a authorization in database is not found, user will be redirected to a page, where he can request a new code to be sent to his email
Once code is requested, user is sent to a second page, where he can enter the code emailed to him.
If the correct code is entered on the second page, corresponding record is updated to reflect the authorization, and user is redirected back to the original page he tried to access.
Now we will hit the first step again, find the authorized record in local db, and will create the cookie.
Other requests should proceed normally as now there is a cookie in the request.

My questions are:

Any obvious issues in this solution, to which I've been blind?
Are there any tools/frameworks which could be useful in implementing this kind of requirement?
Any best practices/patterns/anti-patterns that I'm not aware of applicable to this kind of scenarios?

DO NOT USE IP ADDRESSES FOR AUTHENTICATION

Once that's off the table, what you describe is a "remember me" function for a web application. This has been discussed frequently here.

(and product recommendations are off-topic)


For DHE_RSA_.. Cipher Suites what is RSA used for? In addition to achieving PFS with DHE, we want as little as possible to be revealed when the server's private key is revealed. So, what is RSA used for in DHE_RSA cipher suites? What does the server sign during the key exchange?

In a cipher suite like "TLS_DHE_RSA_WITH_AES_256_CBC_MD5" RSA is used for authentication, while AES (256 bit) in CBC mode is used for encryption.

Authentication is needed since Diffie-Hellman is vulnerable to Man-in-the-Middle attacks. An attacker could easily exchange the Diffie-Hellmann paramater and would therefore be able to intercept the communication later. So signed Diffie-Hellman parameter ensure, that a Man-in-the-Middle attack would be detected. There is a variant of Diffie-Hellman key exchange called anonymous Diffie-Hellman (DH_anon) which doesn't use authentication.

The server signs the Diffie-Hellman parameter (via RSA) from which the so called pre-master secret is derived. From the pre-master secret the master secret is later calculated, from which in turn the symmetric 256 bit AES key is generated. Remember that the Diffie-Hellman parameter being exchanged are public, so they are not encrypted with RSA. They just get signed.

I took most of this from here which is a nice summary of the whole topic. Unfortunately it's only in German, but maybe the figures still help you. You can find more detailed information in RFC 5246.


Where do people who publish "free proxies lists" get their proxies from? Where do people who publish "free proxies lists" get their lists from? I know those lists are commonly used for example by so called "internet marketers" for scraping websites. Search for "free proxy list" if you don't know what I'm talking about. Do people who publish them scan for misconfigured routers so that they can use them to proxy their traffic?

How many percent of those routers you think are home routers? That would be unethical to me because you basically hijack somebody's connection and slow it down for them and just leave the vulnerability for other people to exploit (who may do worse things than innocent scraping of websites).

Furthermore, would it possible to reach the IP owner somehow and inform them about the issue? If that's a home router, would writing to the ISP who may then contact the subscriber and help them work?

Mostly the hackers will find the vulnerable proxies over the internet by running scanners to find servers lisitining to the web proxies common ports (8080,3128,8000)
For the second part of the question normally any used public IP on the internet will have contact info for the IP owner and you can reach that information from whois.iana.org which will guide you on which site you will find more information related to the IP.
You can contact the IP owner (which is normally ISP)


Can the xxhash seed be found given a large set of hashes? xxhash clearly states that it's non-cryptographic, but I have had trouble comprehending what this practically means. Does this mean that the seed and/or input could be reconstructed given a very large number of hashes?

(Assume the seed is a random 8 bytes of data and the input itself can not be guessed either by hand (although the input values are related))

A cryptographic hash has several properties (from Wikipedia) :

it is quick to compute the hash value for any given message
it is infeasible to generate a message from its hash value except by trying all possible messages
a small change to a message should change the hash value so extensively that the new hash value appears uncorrelated with the old hash value
it is infeasible to find two different messages with the same hash value

A hash function like xxhash doesn't need those properties - it is intended for things like hashtables and instead looks for sheer speed and good distribution of values.

One note : by "it is quick to compute the hash value for any given message" for a cryptographic hash, they really mean it is PRACTICAL rather than quick.  One of the problems with MD5 (which was considered a cryptographic hash, but now is considered broken) is that it has reached the point where brute forcing short passwords is practical, because GPU based clusters can do ten billion tries a second or so. That isn't all that is broken about MD5 - there are some mathematical attacks on the hash as well, but it doesn't help. Bcrypt/scrypt/SSHA512 all are much, much slower, but still practical for normal usage.


Publish a public key I am starting to use email encryption with a pair of keys (private and public). So far and after several days of tests, I have been able to send an encrypted/signed message. However, the recipient told me "I cannot verify the signature because you seem to have not published your public key".

This is, in fact, the first encrypted message I have sent in my life and I do not exactly know what I have to do to fulfill the requirement. The only thing I can think of is about publishing my public key to a key server but I am not sure if this is the solution.

I assume that you're using PGP (as in, any program that implements the OpenPGP standard, such as GnuPG). That's the de facto standard for exchanging encrypted or signed email between people who aren't in the same organization.

When an email has a valid signature, verified against a public key, that proves that the message was sent by someone who has the private key corresponding to this public key. This is only half the battle to know who sent the email: the other half is knowing who the public key belongs to.

If you send your public key to your correspondent, they can verify that it matches the key used to sign the email. You need to do that. You can send it as an attachment to an email, and email software that supports PGP often has an option to make this convenient (something like “attach my public key”). If your email software doesn't have this option, you can use your PGP software to export your public key, for example copy-paste the output of gpg --export JORGE@example.com (replacing JORGE@example.com by the email you used in your key).

That allows your correspondent to verify the signature, but it may or may not satisfy them that you are who you say you are. To satisfy that, you have to allow them to relate that public key with what they already know about you. For example, if they have your phone number, you could tell them to ring you, and then compare your public key's fingerprints — this is a short sequence of digits and letters that is unique to a public key. Your PGP software can display your key's fingerprint (e.g. gpg --fingerprint JORGE@example.com). Another method is to have someone that both of you trust sign your key. That is, Charlie (some guy you both trust) comes and verifies that the key is yours (by whatever means), and then uses PGP to emit a “certificate” that says “this key belongs to Jorge”. Such certificates form a web of trust.

You can upload your key to a key server for convenience, but unless you're part of an organization that uses a key server, that won't do much good. Putting a key on a key server lets everybody know “there's this key, and there's a claim that the key belongs to Jorge”. But it doesn't prove that the claim is true: anybody could upload any key to the key server. You still need a way to relate the key with some identity of yours, i.e. to include your key in a web of trust.


What hashing strategy is recommended for desensitizing reporting data? I need to desensitize data for reporting.  There may be some PII but nothing like SSN, mostly Name or Phone.  They won't be concatenated together anywhere.  Also this is in the US with no European (or other regions) data.

Given the same key and input the hash needs to create the same output. Therefore I can't use something like bcrypt, I don't believe.

I need to provide a key so that a single input is represented different across different reporting platforms, time periods, etc.  Example the name Fred Flintstone should be unique on a report for 2019, but different in 2020.

From what I read here I assume most hashing algorithms dont use keys.

Since hashing algorithms don't use keys would the best strategy be to pick Blowish or SHA512 and salt using the key?

Since hashing algorithms don't use keys would the best strategy be to
  pick Blowish or SHA512 and salt using the key?

With HMAC you can use secret key to generate hash for sensitive data.

  I need to provide a key so that a single input is represented
  different across different reporting platforms, time periods

Use different key for each different platform or time period.


Which high speed / high security ECC curves are preferred on mobile devices? I'm looking for the most common denominator of ECC curves in consumer devices.

This article describes how a particular ECC curve is ideal for Intel based motherboards.  Since I'll be targeting mobile devices (Android, iOS) and also want to leverage the on-device CPU optimizations for signature verification, I'm looking for an ECC curve that is ideal for them too.

Some things I may need to investigate include

CPU-specific documentation
OS level support
Cross platform interoperability of implementation (encodings, compression, etc)

Question

Since a direct answer to my question doesn't probably exist, what are the most specific resources to figure out which ECC curve to choose for most efficient consumer use?

The general consensus among cryptographers is that Daniel Bernstein's Curve25519 is ideal. It both provides a good security margin while being very fast and using "nothing-up-my-sleeve" numbers, and is supported by a number of libraries. In key exchange, it is called x25519. When used for signatures, it is called Ed25519. It works very well on mobile and embedded devices. In fact, it is so efficient that it is often the choice curve for passively-powered smart cards that utilize ECC!

If you want a stronger curve with similar properties, there is Curve448, also called Ed448-Goldilocks. It is stronger than Curve25519 but is also moderately slower. For a modern mobile device (as opposed to a low-end and low-power embedded device or microcontroller), it is still fast enough.


How to find passwords in memory (password managers) I’m trying to figure out if password managers such as LastPass store passwords in plain text (or hash values that can then be decrypted with the master-password) in memory after a user logs into the browser/extension.

I’m trying to find academic work on this subject but it's hard to find. Does anyone know any academic work regarding this subject?

Also, how to approach this investigation? I plan on getting a complete memory dump of my laptop or would it be better to just get a memory dump of the processes such as browser and LastPass?

First off I used google academic to find papers about LastPass, password managers and memory forensics. It was the last one I found to be more helpful

Amari, K. (2009) Techniques and Tools for Recovering and Analysing Data from Volatile Memory.

After gaining an understanding memory extracting and analysis I created a windows 7 virtual machine with 2 GB of RAM, installed some browsers made a few accounts on various websites, installed LastPass, restarted the machine and captured a memory dump using DUMPIT (Search DUMP IT Memory dump). I analyzed the memory dump using SIFT Workstation, in the terminal I used the command

strings windows7.raw | grep “password” > output.txt

Swapping "password" for email addresses, known passwords of the fake accounts, website names etc.. I found nothing, so the memory was clean.

I then logged into LastPass and took another memory dump using the same tool. Analyzing this file highlighted a bunch of hashed values, which confirmed what LastPass says on its site - LastPass stores encrypted hash values in memory.

Next I decided to log into websites and accounts but not all of them just a random number of them and took another memory dump. Using the same methods as before I found decrypted passwords, email address and other information this means that when you visit a website that LastPass has a password for, it decrypt's it and stores in the memory for your browser to use.
I should also state that even if you don’t use LastPass and instead use a browser(s) built in password managers you will get the same results.

So you might say that I needed to know the password in the first place, I didn’t as simply searching for “pass” or in the case of google websites “Passwd” in the memory dump gave the passwords.

If I do this again I would do all the same steps above however, I would log out the windows account and into another account to see if I can get the the passwords from that memory dump, I suspect you would meaning you can log into a public computer and obtain the previous users passwords from there memory dump.

I would say that LastPass is secure until you log into a website, its very unlikely anyone will be able to decrypted the hashed values. In the end don't use LastPass or any other password on a public computer.


Why does rfc6797 say "An HSTS Host MUST NOT include the STS header field in HTTP responses over non-secure transport." Why does the RFC prohibit the server from sending HSTS to the client over HTTP?

I can see that if a HTTP client responds to that unsecure HTTP response it might cause that site to be inaccessible to the client, but I don't see any reason for the server to have a MUST in the protocol.

Rather the client MUST NOT respond to HSTS in unsecure HTTP responses is the correct approach in my mind.  What am I missing?

  7.2.  HTTP Request Type

  If an HSTS Host receives an HTTP request message over a non-secure
  transport, it SHOULD send an HTTP response message containing a
  status code indicating a permanent redirect, such as status code 301
  (Section 10.3.2 of [RFC2616]), and a Location header field value
  containing either the HTTP request's original Effective Request URI
  (see Section 9 ("Constructing an Effective Request URI")) altered as
  necessary to have a URI scheme of "https", or a URI generated
  according to local policy with a URI scheme of "https".

  NOTE:  The above behavior is a "SHOULD" rather than a "MUST" due
  to:

  Risks in server-side non-secure-to-secure redirects
       [OWASP-TLSGuide].
  Site deployment characteristics.  For example, a site that
       incorporates third-party components may not behave correctly
       when doing server-side non-secure-to-secure redirects in the
       case of being accessed over non-secure transport but does
       behave correctly when accessed uniformly over secure transport.
       The latter is the case given an HSTS-capable UA that has
       already noted the site as a Known HSTS Host (by whatever means,
       e.g., prior interaction or UA configuration).

  An HSTS Host MUST NOT include the STS header field in HTTP
  responses    conveyed over non-secure transport.

This client behavior is prohibited by section 8.1 of the RFC:

If an HTTP response is received over insecure transport, the UA MUST ignore any present STS header field(s).

The spec prohibits severs from sending insecure HSTS directives and clients from processing insecure HSTS directives. This ensures that a faulty implementation in either a server or client is not sufficient to undermine HSTS; the failure must be present in both for the weakness to be present.

As noted in your question, HSTS over plain HTTP sounds like a great way for an attacker to implement long-term client-enforced denial of service on a service offered over HTTP. In fact, section 14.3 of RFC 6797 addresses this specifically (as well as an even more serious concern):

The rationale behind this [requirement that HSTS be served over secure connections only] is that if there is a "man in the middle" (MITM) -- whether a legitimately deployed proxy or an illegitimate entity -- it could cause various mischief (see also Appendix A ("Design Decision Notes") item 3, as well as Section 14.6 ("Bootstrap MITM Vulnerability")); for example:

Unauthorized notation of the host as a Known HSTS Host, potentially leading to a denial-of-service situation if the host does not uniformly offer its services over secure transport (see also Section 14.5 ("Denial of Service")).

Resetting the time to live for the host's designation as a Known HSTS Host by manipulating the max-age header field parameter value that is returned to the UA.  If max-age is returned as zero, this will cause the host to cease being regarded as a Known HSTS Host by the UA, leading to either insecure connections to the host or possibly denial of service if the host delivers its services only over secure transport.

Since HTTP can be easily spoofed, an attacker could specify an HSTS directive to treat an HTTP-only site as an HTTPS site: the client would then demand HTTPS and the server would be unable to supply it.
More seriously, this section of the RFC indicates that an attacker who can issue HSTS directives for a host could strip the host's status as a Known HSTS Host, thereby dangerously allowing the client to issue plain HTTP requests to the host.


Sending non-expiring access token on each request vs using refresh tokens? When securing REST APIs for mobile applications, what you often see is the use of refresh tokens. They exist because:

Access Tokens have expiration date.
We don't want the user to have to enter his credentials.

Refresh tokens are revokable tokens with no expiration dates that can be used to retrieve a new access token when the later has expired. See here.

On all your API calls, the (valid) access token will be sent. When it's expired, you use your "special key" (the refresh token) to get another not-expired access token.

How is this broadly used pattern anyhow inferior or different from just issuing a non-expiring access token and storing it in the device, just the same way you would have stored your refresh token?

PS: If your answer to this is that sending the non-expiring token on each request is less secure (middle man), I would argue: is it really when your API is over HTTPS? (Plus you do send an non-expiring token on the same network anyway, you just call it "refresh token" and send it less often).

PS2: If your answer relates to the ability to revoke refresh tokens, then I guess I could argue that we could make our access tokens revokable as well.

When working - for example - with JWT tokens, the tokens are self-signed.
Which means that the resource service can verify the token's integrity without having to communicate with the authentication server. Which is fine to do with short-lived access tokens.
But when the refresh token will be used to acquire a new access token from the authentication server, the authentication server could be performing more validation like checking if the session was revoked or if the user's account still exist, is still active and still has the rights to access the resource service for which it will issue a new access token.

In that case, using refresh and access tokens can help you implement simpler validation mechanisms for short-lived access tokens, allowing faster response from your resource server.


Best methods to mitigate DDOS with changing IP sources Source ip addresses can be spoofed. And because of IPv6 it is not enough to keep a look-up table of ip addresses that are excluded from visiting a website, because with ipv6 there are now enough ip addresses for a single sender to spoof to send quintillions of probing requests at a webserver.
Given this, what are newer methods of mitigating rotating IP forwarded DDOS probes of a web server?
Is the only solution to white list individual registered user's ip addresses and also to ____ ?

If you are worried about the amount of IPv6 addresses you can treat whole blocks of /64 or /62 the same way as you treat one IPv4 address. If you are receiving a lot of traffic from different addresses in the same /64 net you can block the whole net for a while to prevent attacks.
You can also use a service like Cloudflare to put in front of your own service to mitigate DDOS attacks. This way Cloudflare will be the public IP addresses of your website, while your own server's IP address can be hidden and can configured to only accept connections from Cloudflare and block all other requests. Cloudflare will mitigate DDOS attacks and can also cache parts (or all) of your website in local CDNs all over the world and provide other techniques to improve the speed of your site as well.


How exactly does the Stagefright Vulnerability work on Android? Digital Trends describes the Stagefright Vulnerability thus:

  The exploit in question happens when a hacker sends a MMS message containing a video that includes malware code. What’s most alarming about it is that the victim doesn’t even have to open the message or watch the video in order to activate it. The built-in Hangouts app automatically processes videos and pictures from MMS messages in order to have them ready in the phone’s Gallery app.

How is it that a video file that hasn't been 'played' yet can be used to execute malicious code? Would anyone be able to give a more low-level explanation of how this is possible?

P.S.: To protect yourself just make sure to disable all the 'Auto-Download' features for MMS in your messaging apps (Hangout, Messaging, etc.).

The details will be released on the 5th of august. However, on the Cyanogenmod github repository there are several interesting details that appear to be related: it appears that certain fields in 3GPP video metadata are vulnerable to buffer overflow attacks. In short, a 3GPP video can be given a string of metadata that, at first, exceeds a certain length, and in the end includes machine code that lands in memory that is off-limits to the application.

Update: Cyanogenmod has released a patch for this vulnerability.


What privacy considerations are needed when choosing a payment processor? I'm looking for a payment processor to integrate with my app or website and want to reduce the risk of my purchases being logged, analyzed by artificial intelligence, or have copies of that transaction exposed to as few third parties as possible.

Can someone define the nouns (payment processor, networks, institutions) and what has the most privacy guarantees?

To limit the scope, this is an online or in person purchase from a US person to a US based company).

Can someone define the nouns (payment processor, networks, institutions) and what has the most privacy guarantees?

I can define the nouns, but the short of it is - there are no privacy guarantees you can count on, except that the companies involved prefer to avoid the legal and reputational impact of data breaches.

(This answer excludes constraints imposed by the GDPR, as you've explicitly limited scope to "an online or in person purchase from a US person to a US based company")

Let's start with the parties involved -

Card Brands - Visa, Mastercard, American Express, etc. etc.  These are the central clearinghouses that facilitate transaction.  When you use a credit card, your transaction details will traverse the chain and get approved or declined by the card brand shown on the card.  The Card Brand owns your transaction details.

Acquiring Banks act as the backend for the merchant; when a credit card transaction is approved, the acquiring banks sends money down the chain to the merchant, and then collects the money to cover that from the Issuing Bank.  The Acquiring Bank owns your transaction details.

Issuing Banks issue credit cards to people ("cardholders").  They send the money for transactions to the Acquiring Bank, and then collect the money to cover that from the Cardholder.  The Issuing Bank owns your transaction details.

Payment Processors act as an aggregation point between Merchants, the Card Brands, and the Acquiring Banks.  Rather than having each merchant try to set up connections to each Card Brand and an Acquiring Bank - which is complex, hard work - the Processor provides the value-add of simplifying the process for both ends of the chain.  The Processor also owns your transaction details.  There may be multiple processors in the chain.

The Merchant is the store that charges people's cards in return for goods or services.  When you say "I'm looking for a payment processor to integrate with my app or website" you're saying "I want to be a Merchant."  The Merchant has to have a relationship with a Payment Processor (the majority), or directly with the Card Brands and an Acquiring Bank (a rarity).

Either the Merchant or the Processor may involve Third Parties, such as Fraud Detection clearinghouses.  A Fraud Detection company may, for example, work with multiple Processors, and provide the value-add that it has a more complete view of card and fraud activity than any single Processor can have.

And the data???

When someone uses a credit card, the details of their transaction traverse the chain and everyone involved gets a copy.  Those transactional details are required for the credit card process to work.  Have you ever disputed a fraudulent charge?  In order to do that, all the parties involved have to have a record of that charge.  The various Card Brands have different policies on how long information must be available to support a disputed charge, but as a rule of thumb, you can expect that 18 months is the minimum your transactional data will be available for use by each link in the chain.

In addition, each one of those entities considers the transactional data valuable in its own right.  The Card Brands, for example, have sophisticated AI that is constantly working to predict fraud more correctly, which includes knowing about past transactions.  Processors are constantly performing data analytics to provide value-add services to the Merchants, explaining trends in the data that Merchants lack the resources to delve on their own.

All their contracts say they can do this.  All their contracts include the ability to share the data with third parties that will do more of it.  When Merchants sign a contract with a Payment Processor, they are agreeing to these usages.  When cardholders open that thick envelope of fine print with a credit card in it, and sign the card, they're indicating they read and agree with all the contracts that allow this usage.  If they don't agree, their recourse is to destroy the card and not use it.

So to take this back to your original question, you

  want to reduce the risk of my purchases being logged, analyzed by
  artificial intelligence, or have copies of that transaction exposed to
  as few third parties as possible

Presumably when you say "my purchases" you mean "purchases customers make against my application/web site", which means you are a Merchant.  As such, all you can do is shop around and examine the contracts offered to you by the various Processors.  Unless you are large, you will likely be seeing standard contracts, and unless you are very large, you will not have room to negotiate those contracts.

Those contracts will basically say, they will protect the data, and can do various things with the data, including analysis and sharing with third parties.  They may list third parties, and reserve the right to change the list.  I would be surprised if you find any significant outliers there; that's not an area the Processors use to differentiate themselves, in part because they're only one link in the chain.

And as for the chain, Processor contracts cannot be used to further constrain the Card Brands and the Acquiring Banks.  The sharing of your data with those entities is an inherent and necessary requirement of the contract to process card transactions.

Bottom line: If you want privacy guarantee that your customer's purchases won't be logged, analyzed, or shared, then don't accept credit cards.


sudo restrictions circumvention with pkexec: root shell I had corrupted my sudo setup. With no possibility to login as root (locked root account, broken sudo), a search made it clear: use pkexec. It worked. So far, so good.

But that turns out to be a big security hole: a user that is part of the 'sudo' group can always gain root access, and start a shell as the root user. That is, at least on a default Ubuntu server installation with sudo.

This renders sudo useless as a means to restrict elevated privileges to certain commands for selected users. Unless some policykit policy is altered, apparently. That's not mentioned in the man pages of 'visudo' or 'sudo'. And I've never seen it mentioned in any tutorial on how to set up the sudoers file (probably I've been reading the wrong tutorials, then).

Can anyone point me into the right direction? What policykit, or sudo, configuration file needs to be changed (and how) in order to accommodate privilege escalation for one specific command, for one specific user?

As an example, I want the 'sudotest' user to only be able to run the command 'cat /proc/tty/driver/serial' which results in a 'Permission denied' error for non-privileged users.

Setup:

Ubuntu bionic
user 'sudotest', part of 'sudo' group
either: single sudo command for 'sudotest', or even none

me@some-server:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.2 LTS
Release:    18.04
Codename:   bionic

me@some-server:~$ ls -l /home
total 20
drwx------ 6 me  me   4096 May 17 15:17 me
drwx------ 2 root root 16384 Nov 26 17:20 lost+found

me@some-server:~$ sudo cat /etc/sudoers | grep -v "^#\|^$"
Defaults    env_reset
Defaults    mail_badpass
Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin"
root    ALL=(ALL:ALL) ALL
me  ALL=(ALL:ALL) ALL
%admin ALL=(ALL) ALL

me@some-server:~$ sudo useradd -m -d /home/sudotest -s /bin/bash sudotest

me@some-server:~$ sudo gpasswd -a sudotest sudo
Adding user sudotest to group sudo

me@some-server:~$ sudo passwd sudotest
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

me@some-server:~$ su - sudotest
su - sudotest
Password:

me@some-server:~$ $ groups
sudotest sudo

sudotest@some-server:~$ sudo -l
[sudo] password for sudotest:
Sorry, user sudotest may not run sudo on some-server.

Hey, this user can not even do anything with sudo. Looks like an unprivileged user.
Still, this user is perfectly capable of gaining a root shell using pkexec.

How can I prevent this?
What configuration options do I have to allow this user to execute one single command of my choosing with elevated privileges?

Update:
This is different from the linked question in that I want to know how I can (safely) limit a specific user to be able to execute one specific command with elevated privileges with sudo on a system that has polkit installed by default, which, apparently, allows any sudo user to gain a root shell.

a big security hole: a user that is part of the 'sudo' group can always gain root access, and start a shell as the root user. That is, at least on a default Ubuntu server installation with sudo.
This renders sudo useless as a means to restrict elevated privileges to certain commands for selected users.

As far as I know that is no actual security problem, except maybe in your expectations. Your conclusion is completely unwarranted.

Since Ubuntu 12.04  administrator access is  granted via the "sudo" group.

Administrators need full and unrestricted superuser access to be able to perform their tasks.

This policy is consistently implemented in the default policies shipped by Ubuntu for both sudo and polkit, which allow all sudo group members to run both commandline and graphical applications as root.

(You then modified /etc/sudoers to remove the default policy for sudo group members but didn't modify the polkit policy. That led you to the mistaken conclusion that a member of the sudo group looks like unprivileged user, when they are (still) administrators with respect to other authentication systems. )
The solution is of course also obvious:

Don't make users a member of the sudo group when you don't want to grant them full superuser access.

For limited superuser access you will have to create your own policies in either sudo, polkit or both. You should create specific policies for particular users, or create new groups of your own for group based access controls.


Nmap --script-args usage? I'm trying to use multiple Nmap --script-args at the same time.

$ nmap -vv -p80,443 --script http-errors --script-args "httpspider.url=/,httpspider.maxpagecount=3,httpspider.maxdepth=1" website.com

I tried encasing the args in double quotes, single quotes, no quotes, and quoting the values after each = sign. But the scan always returns the same "maxpagecount":

PORT    STATE SERVICE REASON
443/tcp open  https   syn-ack
| http-errors:
| Spidering limited to: maxpagecount=40; withinhost=website.com
|   Found the following error pages:
|
|   Error Code: 403
|_      https://website.com:443/

specs:

$ nmap --version

Nmap version 7.70 ( https://nmap.org )
Platform: x86_64-pc-linux-gnu
Compiled with: liblua-5.3.3 openssl-1.1.0h libssh2-1.8.0 libz-1.2.11 libpcre-8.39 nmap-libpcap-1.7.3 nmap-libdnet-1.12 ipv6
Compiled without:
Available nsock engines: epoll poll select

$ lsb_release -a

No LSB modules are available.
Distributor ID: Kali
Description:    Kali GNU/Linux Rolling
Release:    kali-rolling
Codename:   kali-rolling

Am I doing something incorrectly or could this be a bug in Nmap?

The script will always have that line as the default is 40 pages. See the manual page you linked. Specifically:

  The script, by default, spiders and searches within forty pages. For large web applications make sure to increase httpspider's maxpagecount value. Please, note that the script will become more intrusive though.


What are the Standard Practices for Securely Storing Encryption Keys in Databases I have a requirement for storing multiple symmetric encryption keys in a database. What I want to know is, are there any standard, accepted practices for storing these keys in a database ?

To add a bit of context, I know that encrypting the encryption key itself is a bad idea because, then where would I securely store that encryption key which was used to encrypt the other keys.

So just want to know if there is any known standard practice for getting this done.

When you are facing such a (pain in the ass) problem, please, consider first using an existing solution for key management, I am sure you will be able to combine this solution with the software you are developing, if you really want to go on, then continue reading.

Don't overkill. Consider if the environment you are in is safe enough for the purpose of the key. Although it is not a good practice, storing the key as plain text may be reasonably ok for you.
If this is a high security environment don't DIY, buy a solution.
If you want to go on =), you have to consider not only the secure storage of the key, you have to ensure also its transmission and its format.
If the key is used by an script of unattended software, eventually they will need the key as plain text, so consider again if it is worth.
If the keys are used by users (using a software), you can always store them encrypted with an user password, but consider that it will be the user the one who decypher it, so you will need to send him the encrypted-key.
There are a lot of implications with key management, be sure you fully understand whats behind in this topic.

You can have a look also to these NIST guides:

http://csrc.nist.gov/groups/ST/toolkit/key_management.html


Bridge Firewall vs Routing Firewall What is the difference between bridge and routing firewall ?

How they both works and what are the security advantages/disadvantages for both scenario ?

A routing firewall participates in the IP process, whereas a bridging, or transparent, firewall does not. A transparent firewall acts more as a tap on a line, while a routing firewall has to forward traffic onto its next destination.

The advantages of a transparent firewall are that it can be installed in-line between two devices without having to reconfigure the IP subnet used as the interfaces on the firewall are unnumbered. From a security perspective a transparent firewall is quieter, as it does not participate in IP connections an attacker may not even know it is there unless something is blocked. An attacker will have difficulty determining the type of firewall being used.

The advantages of a routing firewall is that as it participates in the IP protocol it can do network address translation, port translation, and tricks like source port scrambling to make fingerprinting more difficult. A transparent firewall provide these types of services.

As for which to use it depends on the problem you are trying to solve. Routed firewalls provide the most capability and flexibility, but transparent firewalls can be inserted into connections without requiring substantial network changes.


BIOS upgrade only with PGP-signature / encrypting the whole BIOS To successfully defend the BIOS from malicious rootkit installation or other malware that writes itself inside BIOS I wonder if these ideas are possible or even done yet:

Can you program the BIOS itself in a way that it only accepts data to be written to the BIOS that has been signed with the BIOS-Manufacture's PGP-Key? Basically the same way like normal userland programs get their updates installed.
Is it possible to encrypt the whole BIOS data to prevent attackers from just 'upgrading' your BIOS with their malicious code?

In both ways it would be sufficient to protect the BIOS only from write-to-BIOS access. While reading from BIOS doesnt require authorization.

Edit: Is there any way to implement this on your own? Like you secure your HHD with Bitlocker or verify a peer with public key cryptography.

You could use UEFI secure boot. 800-147 is all about authenticating firmware updates - it states that BIOS code itself should be protected by a keypair:

To prevent unintended or malicious modification of the system BIOS outside the
authenticated BIOS update process, the RTU and the system BIOS (excluding configuration
data used by the system BIOS that is stored in non-volatile memory) shall be protected
from unintended or malicious modification with a mechanism that cannot be overridden
outside of an authenticated BIOS update.  The protection mechanism shall itself be
protected from unauthorized modification.


How to pentest an AngularJS based SPA (Single Page Application) I am trying to Pentest an application which is built in AngularJS. The difficulties that I am facing:

Burp Suite's "spider this host" option is not able to crawl all the urls as most of the requests are AJAX and Angular based.
When I am trying manually to parse all the links using Burp Suite. It is able to parse only home page link. Rest clicks are not intercepted.
I am not able to get the contents of the  templates used for various layouts. Like: "App/src/dashboard/Menu/Menu.box.tpl.html" is one of the template used in Angular Directive. But how to parse its html contents. (Just like we get html source for general parsed urls).

Here, Acunetix was bit helpful to give the brief idea how the application is parsing the contents. But for manual pentest I am not getting proper solution like which tools, methods etc I should use.

Please guide me if anyone knows about Angular App pentesting methodologies.

Is there any link/resource/tutorials out there for AngularJS app pentest?

Used to teach app pentest classes for a Fortune 20 appsec vendor to Fortune 100 clients. Years ago the state-of-the art for these types of assessments was the OWASP Ajax Crawling Tool where one had to manually input all of the Ajax parameters and actions.

For AngularJS, there is the AngularJS Batarang Chrome Extension in the Chrome Extension Store -- very useful for debugging. If you also happen to run into Node.js (likely), then you can also leverage the iron-node debugging tool. If you do any Javascript prototyping or development, I also suggest checking out the ternjs (Intellisense-like) add-on to the Atom Editor. nVisium Security wrote up a blog post on some of the security issues in AngularJS. Dinis Cruz also writes on AngularJS regularly.

Single-Page Applications can be worked much more efficiently using BurpKit, and to get an efficient crawl, check out htcap.


If clients broadcast SSID's anyway, does it make a difference if AP is hidden or not? In this link, it is explained why a client sends probes to a hidden network: link
And here it states that clients will send probes for any network to save battery: link

So does it make a difference from a privacy perspective if clients are broadcasting the SSID anyway?

Because hiding it would help against wardrivers and google pinning the SSID to a location.

First, we agree that hiding the SSID is not a security feature. But it can be handy sometimes because the attacker needs at least one connected client to a hidden network to send de-auth and get the SSID.

Most important, hiding the SSID might affect client's privacy. Because the client is broadcasting a trusted network SSID, so a rogue AP can be set by an attacker, and then he might be able to set mitm. "only if the network is set to open auth"

Check this answer for more,


Let's Encrypt for intranet websites? Many companies have intranet websites that are not reachable via the internet. Usually they just use a self-signed certificate, which causes a bad habit for the users since they get used to just pressing OK on invalid CERT warnings.

Question: How can they generate a certificate for their HTTPS websites using Let's Encrypt? Does the LTS web browsers have the Let's Encrypt as CA?

Isn't it a privacy issue that private domain names, like my-company-private-intranet-site.com, could be leaked?

Let's Encrypt can only issue certificates for valid DNS names. So if your intranet uses a made-up domain name like intranet.mycompany.local then it won't work.

If you have a real DNS name like intranet.mycompany.com (even if it doesn't resolve externally to your intranet), then you can use Let's Encrypt to issue certificates for it. If the domain does resolve externally to a server that can respond on port 80 (which need not actually be part of your intranet, if you have split-horizon DNS), you can use the http-01 challenge.

Alternatively, you can use the dns-01 challenge (fully supported in Certbot 0.10.0 and later, as well as other clients such as dehydrated, getssl and acme.sh). Since this challenge works by provisioning DNS TXT records, you don't ever need to point an A record at a public IP address.

So your intranet does not need to be reachable from the Internet, but your domain name does need to exist in the public DNS under your control.

Let's Encrypt - and publicly trusted certificate authorities in general, due to Chrome's requirements - submit all issued certificates to public certificate transparency logs. As such, you should not expect your intranet (sub)domain name to remain secret if you obtain a certificate for it. Your intranet's security shouldn't be dependent on keeping its domain name secret anyway.


How to verify installed packages On Linux (Debian x64) I recently installed some software with:

apt-get install the_package_name

APT told me some packages couldn't be authenticated but I ignored the warning and installed anyway.
Now I want to check if the installed packages are valid. Is it possible to check authenticity of 'installed' packages?

This link gives a pretty good explanation. In particular, this section talks about how to verify packages.

In a nutshell when you install packages your system check that they are signed with a known key, using public key crypto. This guarantees that the packages come from a "trusted" source. In your case some packages were signed with an unknown key and you chose to ignore that warning.

To answer your question I'd recommend to let the system do all the authenticity checks; it's a job computers do much better than humans. All you have to do once is to make sure that your keys are the correct ones.

Please note that my explanation is an over-simplification and that I use the word "trust" loosely; a "trusted" source is a source that keeps their secret key secure. If a malicious attacker were to lay hands on Debian's secret key for package signing there's a much bigger problem than yours.


How can I generate a list of all passwords that apply to a specific rule? So I'm looking for a way to generate a brute force password list that applies to a rule, for example:

  3 letters + 3 numbers

How can I generate a list of every password that applies to that rule?

Use Crunch.

It's a Linux tool, you can find it pre-installed on Kali Linux, check this
 link for more info.

For example, you can use the following syntax to generate your requested rule:

crunch 6 6 -t @@@%%% -o output.txt

the result will be saved in output.txt as the following:

aaa000
aaa001
aaa002
aaa003
aaa004
aaa005
aaa006
.
.
.
zzz992
zzz993
zzz994
zzz995
zzz996
zzz997
zzz998
zzz999

Be aware that using larger syntax will generate a huge sized files.


Possible ways to track down anonymous mail senders? In my previous post here How can I send emails anonymously? the community framed and guided how we can send an anonymous emails through various ways which makes me thought about the following things

Normally we would trace the email using email headers; my scenario is in the following form:

How can we track-down the mail sender if he uses a virtual machine with an IP hiding tool and sending it through anonymous services

What are the best ways to track down this kind of anonymous mail sender?

If the service is working right, you can't.

You can just work with the information that is supplied to you, unless you can gather access to the anonymous mail sending service. This could be possible if you work for a LEA or are able to break into the service (but that would be illegal, of course).
The information that is supplied is the body of the mail, the headers of the mail and attachments. Metadata in attachments can expose somebodies identity.

For example tormail has mailservers working as hidden services and some in the normal internet, so, if you send a mail, you are connected to the hidden service so your IP isn't exposed. Unless he gives the hidden service any information that would compromise his identity, you can't get anything to track him down.


libsodium nonce and captcha validation so, I want to implement server which validates registration with captcha. First I thought about storing captchas in a server, but then I thought it would be hassle on caching, memory, what if I need to write it into file, etc... But then I had this genius idea (probably someone else already did it), how about just send captcha to the client, also send the encrypted answer, and when user answers he sends the captcha (or maybe a digest of it, if it's a little bigger) and I can simply decrypt the answer out of the client. BOOM, I don't need to store bazillions of images at all and I can scale these up as much as I want! (different server could send out captcha and different could serve the response).

Now, I just have one problem. I need a nonce to encrypt stuff in libsodium. Like in here http://doc.libsodium.org/public-key_cryptography/authenticated_encryption.html . Now, if I generate this every time, send to the user for the user to send it back, then it is public, what is the point of that? Or, if I use constant nonce then, still, what is the point of that? Server and client can look it up.

What should I do here? Should I use constant nonce in this situation or should I generate it every time and why?

If it is stateless, your scheme is vulnerable to replay attacks.

A client can respond with the same captcha+ciphertext every time, no matter what ciphertext was initially sent.

Use a timetamp+random bytes as a nonce. This doesn't have to be secret, only the key must remain secret.

Instead of encrypting the captcha, you can use a keyed hash.

Server sends Hk(captcha) || timestamp || randombytes with k = secret || timestamp || randombytes. You can use crypto_auth() or crypto_generichash() for this, and use a 192-bit secret, a 32-bit coarse timestamp and a 32-bit random part.
Client sends Hk(captcha) || timestamp || randombytes || captcha
Server computes H'k(captcha) using the captcha, timestamp and randombytes sent by the client, and verifies that the timestamp is close to the current time and that H'k(captcha) matches Hk(captcha).


Function of %5c.. in a path traversal I've recently come across this blog post of a bug bounty hunter.

Apparently, a path traversal vulnerability was discovered, which looked like this:

 http://help.example.com/@app/skin/views/%5c../%5c../%5c../%5c../%5c../%5c../%5c../etc/passwd.html

I've never come across such a format for a path traversal.

How does this work and what is the purpose of the URL encoded backslash in %5c..?

"%5c" (encoded backslash) is commonly used to circumvent sanitisation of the "../" (forward slash) in a URL - tries to stop directory transversal via the URL. As you can't have a backslash in a URL it needs to be encoded.

So if the forwardslash is blocked the backslash may work - allowing the attack.

I've seen this more often on IIS attacks rather than Linux/Unix servers.


What are the best practices to secure an Angular & Spring web project? I'm creating WEB project in Angular4 and Spring. This is educational project for my learning.

I want to encrypt some data in Angular and then store it in backend. Idea is to not have any acces to user data in backend - user will be more sure that his data is not sended to server, it is not possible to steal it, sell it etc.

How can I make this site secure? Good encryption in Angular before sending to DB is basic, but what else? Some kind of RAM encryption to secure frontend? Some kind of frontend isolation? Any extra security from backend? What else can be done?

I think my main concern is if anyone can acces RAM and see users password stored - enven if I clear it as soon as possible. I'm asking about your general thoughts in this security area.

I'll write a little more about idea. There will be possibility to put some sensitive data in frontend. And then frontend is encrypting it (using users password) and sending to backend. So, I'm a little afraid about this user password which need to be clear text in browser memory - at least during encryption in Angular.

[AngularJS] Common Pitfalls

AngularJS makes it very easy for developers to get in to some dangerous territory. Here's some common things that I see when I assess websites using AngularJS, regardless of the backend:

Lack of server-side session validation
Lack of server-side input validation
Decoupling the frontend from the backend and forgetting things like output encoding

Lack of server-side session validation

The near-universal pitfall I see is that the frontend handles all of the session checking and routing, but I can just call the backend endpoints and be anybody I want to be. AngularJS also has this cookie thing it does with defining the user permissions in the cookie. Don't do that. I can manipulate that cookie and send it to the server.

To avoid this, do your session checks server-side.

Lack of server-side input validation

Another common pitfall I see is that AngularJS gives a lot of nice tools to developers to do things like routing, input validation, all in a nice, rich UI. However, those input validations aren't done server-side.

To avoid this, enforce validation checks on both sides.

Decoupling frontend and backend

As mentioned, AngularJS gives nice things to developers. However, when the backend and frontend are decoupled for things like UI generation, routing, it is easy for developers to forget where the data is coming from and forget to properly output encode. AngularJS does do some things to help you, and newer versions target output encoding specifically, but ensure that you do it correctly.

[Spring] Common Pitfalls

For the most part, the advice I give is independent of any framework chosen. However, the backend is much larger, and I could write a book. So instead, I'll try to limit it a bit, especially given the question.

Ensure the framework is properly configured. Frameworks like Spring come with out-of-the-box with developer-friendly tools. In the case of Spring, be sure to read up on the production-ready endpoints, for example.
Maintain your patches. No framework is without bugs, and Spring is no exception, having experienced significant security vulnerabilities in the past. Keep your pom/gradle versions up-to-date and you'll be fine.
Review deployment practices. While this is probably starting to get outside the bounds of your question, I want to bring it up because it is part of the learning process.

Encryption

With that all said, now the encryption. Unless you are doing something where the user should be the only one with knowledge of the key, doing encryption in JavaScript is highly discourage.

With user passwords specifically, industry standard, and recommended approach, is TLS. Anybody between the browser and your server will not see or be able to manipulate the data. TLS certificates are free these days, so there's really no good reason not to if it is on the internet. Without knowledge of what kind of data you want to encrypt, I can only give you some common pitfalls of doing something like this in the browser:

Key generation, expiry, storage, and revocation
Ciphertext storage
Encryption algorithm

Keys

Putting aside for the moment your explanation of wanting to use the user password, encryption requires key management. You need to handle generation, storage, expiry, and revocation. This means that you need to have sufficient entropy to generate the key, decide how to handle the key once it is generated, how to handle the key when it approaches expiry and once it has expired, and when the user decides they want to change their key.

In your case, this actually becomes a little more difficult, because now you have to build functionality that'll rotate the keys when they change their password. Otherwise they'll lose access to their old data.

Ciphertext storage

Now that you have the key management, how and where do you store the ciphertext? This becomes a question that matters more for the data you want to encrypt.

Encryption algorithm

Inevitably, you'll need to chose how you want to encrypt the data. Do you use symmetric or asymmetric keys (your stated use case is symmetric)? Now you need to choose algorithm and mode of operation. And randomly generating an IV.

Conclusion

Engineering a solution that can handle encryption on the frontend safely is hard. Really hard. A lot more difficult than handling it on the backend. There are legitimate reasons for doing the encryption on the frontend, but since this is a learning project, I'd encourage you to start on the backend and then work towards the frontend.

There's a lot in this area that I haven't covered and can't cover here for space reasons, and without knowing much more about your objective. In my professional line of work, questions I'd typically start with include:

What data are you trying to protect?
Who are you trying to protect it from?
Are you prepared to handle the unique difficulties on the frontend?

This isn't to discourage you, as there are legitimate reasons for doing this encryption on the frontend. But it is hard to get right, and using the user's password has additional complexities that need to be solved for, some of which I mentioned above.


Authentication and protection against replay attacks on instructions over SSL let there be two clients and a server; the clients have a shared secret and unique IDs.

their communication to the server is encrypted over SSL.

the problem now is sending secure instructions from one client to the other over the server using socket connections and routing instructions to the right client as well as ensuring identity and protecting against replay attacks of those instructions by attackers.

how can this be accomplished securely without compromising client privacy?

(the server should not be relevant to privacy and unable to perform attacks if compromised)

If the clients are communicating with the server encrypted, and we assume we can trust the server, one easy way to do it would be for the server to broadcast some cryptographically random chunk of plaintext to all clients (say, 2048 bits).

The clients cryptographically sign the plaintext with their shared secret(s), and send those signatures to the server, which stores the responses in a hash table, where each response also maps to a list of clients.

When multiple clients give the same signature, the server informs all of them, and each client sends an encrypted packet containing its ID along with a timestamp and nonce, encrypted by the shared key. These packets are then sent to each client in the list, along with a temporary client ID generated by the server.

When a client wishes to communicate with another client, it sends that client's temporary (server) ID to the server. When two clients both send each other's temporary ID to the server, the server transparently creates a tunnel between them. From there the two clients may continue to communicate using their shared channel, sending a timestamp and nonce within each encrypted packet.

Pretty sure this is safe from replay attacks (because timestamp and signing random data), but I'm assuming a strong crypto algorithm, a good crypto signing algorithm, and a cryptographically-strong source of entropy for both clients and the server. Even if someone malicious were to connect to the server during the original signing phase, and were somehow able to guess a working signature (or were able to compromise the entropy source quality of the server, which would create additional problems, anyway, but since we're pretending) they wouldn't be able to get past the peer selection stage where clients choose which other clients they want to connect to.

It does create a DoS opportunity for the server, which really ought to be stateless, but OTOH network connections inherently create opportunity for DoS; either you let anyone connect via SSL, and exhaust memory / cycles / bandwidth, or you start rate limiting, and possibly exclude legitimate users.

EDIT: I answered this question as a theory question, rather than actually giving code or an existing algorithm (AFAIK). Since it's a toy problem, anyway (assuming the server can't be hacked is going a bit far), I thought that would be okay. If that wasn't what you were after, I apologize.


Generic term for certificates and keys Is there a generic term to designate both public and private keys, certificates and maybe even passwords?


Understanding the order by clause used in SQL Injections I am trying to enumerate a database, created specifically for the purpose of learning SQL injections. I am trying to discover the number of columns a particular select statement might be using. I do this by "Ordinal" ordering the result set. So, I start with ORDER BY 1, .. BY 2, and so on until I get an error returning 'Unknown column'. Now, for an injection like so:

localhost/sqli?id=2' order by 7 AND  '1

The resulting SQL statement is:

mysql> SELECT * FROM table_name where id='2' order by 7 and '1';

This returns a result set, but I was expecting it to throw an error returning "unknown column '7' in 'order clause' ". Why does it not throw the error. The table that I am working with has only 3 columns.

If you look at the syntax of ORDER BY clause for the SELECT statement, it states:

[ORDER BY {col_name | expr | position}
  [ASC | DESC], ...]

So you either specify a columns name (col_name), an expression (expr), or a column position (position), where column positions are integers.

Now if you compare this syntax with your ORDER BY clause:

… order by 7 and '1'

7 and '1' is an expression, consisting of an AND operation with 7 and '1' as operands.

However, the following works as expected:

… order by 7, '1'

Where 7 is a column position and '1' is an expression.


Does PHP have a XSS API? ASP.NET has a cross site scripting API by default, however does PHP have a cross site scripting prevention API?

ASP.NET does not provide a XSS API.  I suspect you are talking about Request Validation which is a feature in ASP.NET that inspects HTTP requests and looks for potentially dangerous input.  To my knowledge PHP does not offer anything like this.

While request validation can be a benefit by preventing certain types of XSS attacks, it is not a replacement for properly securing an application from XSS vulnerabilities.  This can be dangerous because it lulls developers into a false sense of security.  In addition to this, request validation can be disabled, so if you are relying on it for XSS protection and then someone else disables it, you are in big trouble.

There is a good post here that talks about some of the shortcomings of request validation in ASP.NET.

So in summary: there is no PHP equivalent of ASP.NET's request validation and you shouldn't rely on request validation to protect you from XSS anyways.


Why is CSRF protection only applicable to web services with browser clients? The Spring docs state:

Our recommendation is to use CSRF protection for any request that could be processed by a browser by normal users. If you are only creating a service that is used by non-browser clients, you will likely want to disable CSRF protection.

I'm interested in why? Why is it OK to disable CSRF protection when building a service whose only clients are non-browsers, but it should be enabled when the service talks to browser clients?

It comes down to the fact that CSRF is an attack against browsers, so if your service is exclusively used by non-browsers there's no point in using anti-CSRF defences, which can be expensive so may be worth disabling.
When a browser interacts with a server, each request comes in separately, so if the service wants to have authentication it needs to add in some scheme to connect requests (to avoid having to have the user authenticate every request). One common way is to set a cookie to the user's browser, which is automatically send when every subsequent request by the browser).

Client logs into service
Server sets a http-only cookie
Malicious script in browser sends a request to e.g. transfer money to the attacker (browser automatically attaches cookie)
User loses money

vs. with protection

Client logs into service
Server sets a http-only cookie
Malicious script in browser sends a request to e.g. transfer money to the attacker (browser automatically attaches cookie)
Server rejects the request as the it doesn't have the correct CSRF fields.

However malicious scripts can make requests to the server, and the browser will helpfully included the cookie. However the script won't have access to the cookie directly (assuming the right cookie option is specified). Therefore a protection against CSRF is to have something in the request separate from the cookie (i.e. a hidden field on a form) that can be verify the request came from a proper form, rather than a script.
CSRF relies on the browser sending the cookie with a cross-site request automatically,  since Javascript/attacker's site don't have access to the cookie.
CSRF protection relies on the server correlating something the browser sends automatically (the cookie) with something in the form (the token).
A non-browser client will be in control of both the token and the cookie so can make them match (if it can get the cookie at all). So there's no point having complicated CSRF protection if the service is never going to be accessed by a browser.
TL/DR - CSRF is inherently a browser attack, so protections against it are only required for services that might be accessed by a browser.


NAS with a public IP and multiple file sharing services – security concerns I've ‘inherited’ (it's now my responsibility to take care of it) a WD My Cloud EX2 with a public IP and since it's exposed to the internet, I want to make sure that the data and other machines on the local network are secure.

I've read that certain services are inherently vulnerable because the traffic isn't encrypted and the authentication methods (signing algorithms?) are weak. Unfortunately, I know fairly little about networking, let alone networking security, so please bear with me.

When I run Nmap on the public IP of the NAS from outside the local network, I get the following list of open ports:

21/tcp    open  ftp
80/tcp    open  http
139/tcp   open  netbios-ssn
443/tcp   open  https
445/tcp   open  microsoft-ds
548/tcp   open  afp
3306/tcp  open  mysql
3689/tcp  open  rendezvous
4443/tcp  open  pharos
8080/tcp  open  http-proxy
8181/tcp  open  intermapper

Sure enough, I can connect from OS X via afp, smb, ftp, and who knows what's Windows using when I boot up a W10 virtual machine and choose to map a network drive as \\ip_address\share (netbios-ssn and microsoft-ds are basically smb, right? this legacy MS stuff is completely beyond me) and I see it just as if it were on a local network.

To me, this doesn't seem safe because I don't know how the authentication and encryption works (unlike ssh, for example) and thus I don't have confidence in this implementation.

I believe some of these services should be behind a firewall because they provide a lot of information about the local network and could possibly be used for an attack. However, the question then is how do I ensure the same functionality, i.e. that any user will be able to map a share as a network drive over the internet and work with files as if they were on a local drive.

Again, I believe I should use a VPN to have clients securely connect to the local network and then access the NAS, or possibly at least isolate the NAS from the rest of the local network (DMZ?).

What are the risks of having a NAS with these ports exposed to the internet and what steps should I take to mitigate these risks?

Thank you in advance.

Risks

Every listening port you leave exposed to the internet increases your risk and likelihood of compromise. I doubt that you have a legitimate need for most of those services, and I'd be willing to bet at least one or more of them is vulnerable, misconfigured, or secured with weak or known credentials.

In addition, some of the remote services may not provide the confidentiality you are looking for due to weak or nonexistent encryption. For example, everything that happens over your FTP service will be plaintext and visible to anyone who is able to observe the connection. Modern versions of SAMBA (SMB services on Linux) may be reasonably secure, but it may be possible to downgrade or man in the middle these connections such that the data or credentials can be read.

So, in short, the risks include unauthorized access, passive interception of data, and complete compromise due to exploitation of a vulnerability.

Mitigation

The ideal solution, as you have mentioned, would be to place this device behind a VPN. That way, you would no longer need to worry about exposure of vulnerable services or protocols with poor security. The only concern is administrative; you need to set up a VPN server and manage how clients will access it.

Alternatively, you could configure a firewall between the device and the internet, only allowing the ports that are absolutely necessary for remote access (you certainly don't need remote MySQL access, for instance). This reduces overall attack surface but does not completely eliminate the issues that the VPN would.


How do VPN providers prevent getting blocked using e.g. Cloudflare, like it is the case for Tor exit-nodes? How do VPN providers prevent getting blocked using e.g. Cloudflare, like it is the case for Tor exit-nodes?

Anyone using Tor to the browse the Internet have experienced that their connection is blocked by Cloudflare or some other service that flags the Tor exit-node as a potential source of malicious traffic.

I guess the traffic of VPN users, e.g. NordVPN, is not more benign than that of Tor users. So, why aren't VPN users blocked by Cloudflare - their Internet traffic is also routed through a fixed set of nodes?

Cloudflare and IP blacklist services do not specifically target anonymity networks. What they do is look at the amount of traffic coming from particular IP addresses or ranges of addresses and catalogue how much of it is malicious. They apply blocks based on how malicious a given address appears to be.

VPN providers do not have any particular technique to avoid this. In fact, popular VPN IP addresses often are heavily blocked. The only reason Tor is more likely to be blocked is the fact that, because it is free, each IP address sees significantly more use, including for spam. This results in services like Cloudflare seeing more malicious traffic coming from Tor exits and applying increasingly harsh blocks. It is true that the list of Tor exit addresses is public. This is an unavoidable aspect of the protocol's design. However, that fact is not a significant reason for why Tor relays are blocked more often.

There are entire third party services which collect IP addresses that have been used for malicious purposes and provide such blacklists to their clients either for free or in the form of a subscription. A popular example would be DNSBL, which contains IPs from both many Tor exits and VPNs.


Nessus: Host Discovery Scan finds no host I am just starting my studies on pentesting and I have created a lab with Virtual Box with two VM's: a Kali-Linux machine and a Metasploitable2 machine. Their networks are both configured to be attached to Host-Only adapter and have no access to any outside network. Kali has IP 192.168.56.101 and MS2 has IP 192.168.56.102. I can ping to the other machine from both of them.

Well, that was the setup. I have installed Nessus on the Kali-Linux machine and I have created a very simple Host-Discovery policy with the template already provided in the software. I set up a scan with this policy and set up 192.168.56.102 as a target, but when I run it, no hosts are found.

I have tried some other policies and scans too, but it never seems to be able to find any host. Is there something wrong with the network configuration for my VM's?

Check on both vms, on network configurations, if both are on the same virtual network and the virtual network card is connected.

Also do some simple connectivity tests like ping and nmap. If nothing works, test if your machine have access to any of the virtual machines and try to sniff the traffic there.

If there is no tcpdump or any other sniffer installed on metasploitable, with I presume that doesn't have any, you can download de .deb file and upload it. Install with dpkg -i tcpdump.deb

If nothing above works, and the packet capture show no packets, take a look into the kernel logs with dmesg, to see if the network card was recognised by the operating system, and check lspci to analyse if the network card is there.


ms08_067_netapi not performing as expected on Windows XP SP1/SP3 I tried the exploit with meterpreter reverse tcp on both SP1/SP3 machines and both returned a statement of exploit completed but no session was created. Both machines have firewall off. I want to have my first meterpreter session opened to experiment with this. BTW, these are virtual machines.

XP SP3 RESULT:

Started reverse TCP handler on [LHOST]:4444
Automatically detecting your target
Fingerprint: Windows XP SP3 English (AlwaysOn NX)
Selected Target: Windows XP SP3 English (AlwaysOn NX)
Attempting to trigger the vulnerability
Exploit completed, but no session was created

There are many reasons for this exploit to fail, in short:

The target is patched.
'Not supported language' error from the target.
The payload can't execute correctly.
Networking errors 'reverse connection through NAT'.

From experience with the same issue, I recommend to do the following:

Try not to use VMs.
Try another payloads, away from reverse connections.
Try other versions of Windows XP.
Change system languages 'sometime it works!'

After all, since it says Exploit completed, but no session was created that means something is preventing the reverse connection, mostly the system is patched.


Is a browser session encrypted using https with just the IP? Accessing a webservice/website via IP with https eg. https://x.x.x.x/
the browser shows that the connection is not secure.

Is the connection actually secure/encrypted or not (more secure than http)?

The problem is likely that the certificate is for a domain name, not the IP. So, when the browser checks to see if the certificate matches the domain, it doesn't.

The connection is encrypted, that's not the problem, but you no longer can be assured that it has been encrypted by the party you hope is doing the encryption (the site you were aiming to connect to). So, it can be possible that someone can sit in the middle of your connection and read or modify the traffic.


Backing up my SSL Private Key On my remote Server, I have SSH configured to only allow logins via Public Key. Currently, only the Key from my desktop machine is allowed to connect.

Now, if I should somehow loose the corresponding private-key, I'd be locked out of my Server. Therefor, I thought I should back that private-key up, preferably on another machine.

Seeing that the private key is encrypted (symmetrically) with a passphrase, can I just put it on Dropbox or Google Drive? Or do I need additional encryption like PKCS #12?

I read similar questions around here and the general consensus seems to be that the private key should never leave the machine it was created on. If that's so, whats the usual procedure for a situation like mine? Do I have to allow password-only logins as a fallback mechanism?

I would strongly advice against putting it on some cloud storage like dropbox because you have no control over the security at their side. But if you must I would suggest that you use KDF when encrypting your private key. (se -a and -o in ssh-keygen manual)

Also some suggest usb sticks, but these break. But of course you could make two. USB sticks are extremely cheap these days. If you then store these in a safe place preferably in some tamper evident seal, like envelopes or actual tamper evident bags, you can be pretty sure no one have used them but you. But of course the key should still be encrypted and use KDF.

My favourite option is actually hardcopy. Basically just print the encrypted key out. If you want you can make a QR code out of it first for better machine readability but thats up to you.

A sort of off topic solution could be to use smart cards to store the keys and have the same key on multiple physical tokens. (pretty similar to the USB stick solution but more secure. Here is a short guide on how to use a yubikey with smart card to store ssh keys:

https://framkant.org/2015/11/using-smart-card-enabled-yubikey-for-ssh-authentication-in-freebsd/


Why does malware modify proxy settings? During dynamic analysis, I have noticed that Adware and some Trojans modify the proxy settings within the Windows Registry. What is the purpose behind making this modification?

The most common keys I have noticed are:

HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable

and

HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyBypass

There are several ways to inject ads or malware into a specific web page:

Inject into the browser itself using DLL injection or browser extensions: How this need to be done is specific for each browser.
Attack the server itself: But then you have only the single server compromised.
Or inject yourself in the connection between browser and server: This can be done be either modifying the proxy settings as in your question. This can also be done by modifying the DNS settings of the system like done by the DNSChanger trojan or even of the whole network by attacking the routers.

Thus changing the proxy is one of the easier ways to inject your ads and malware into all browsers on the system.


How does including a magic prefix to a JSON response work to prevent XSSI attacks? While working on a project that used the REST API for Gerrit Code Review I noticed that they do something that I thought was strange Source:

  To prevent against Cross Site Script Inclusion (XSSI) attacks, the JSON response body starts with a magic prefix line that must be stripped before feeding the rest of the response body to a JSON parser:

)]}'
[ ... valid JSON ... ]

How does prefixing the response body with seemingly random characters work to prevent XSSI?

XSSI works by trying to evaluate a JSON response as Javascript and the sequence )]}' prevents this by reliably producing a syntax error.

There have been different proposed countermeasures against unwanted script inclusion, but putting an infinite loop (I have seen for(;;) used in Facebook APIs) or producing a syntax error (some Google APIs use )]}' as in your example) has shown to be sufficiently sound and is backward compatible. This article has some additional examples.

If you're unsure about why XSSI is a threat in the first place and violates the same-origin policy, read about it here.


what is differential privacy? Currently I have heard a lot about differential privacy but I am unable to find out what exactly it is in a non-mathematicians language. Up-till now my understanding is that it add noise to the answer one gets for his query to database.

The Wikipedia page has mathematics but also an example which may or may not be enlightening: if you can ask a database for the sum of values of a column for rows 1 to n, then doing the request for n-1 and for n allows you to rebuild the information about the row n. Thus, allowing the query "sum of all values for the first n rows" and returning the exact result can be abused into learning exact information for each row.

Differential privacy is the mathematical concept by which how much (or how little) a database preserves anonymity (i.e. avoid issues like the one above) is measured. Adding random noise is a method to achieve (hopefully) some given level of differential privacy. This is not the only possible method, but at least it is relatively simple to implement, and we can compute how much it protects anonymity, i.e., in the mathematical formalism, what is the achieved value of "ε" in the expression "the database ensures ε-differential privacy".

Adding noise is a trade-off: it gives some privacy at the expense of usability, since the returned values are "noisy", thus imprecise. If you want more privacy you must degrade the quality of the database answers. Research on differential privacy concentrates on finding new algorithms for returning more accurate answers to statistical queries while better protecting privacy. Such novel algorithms are heavy in mathematics.


What does "8.11 Encrypt or sign files into an archive" do? I am going through the GnuPG manual and I want to encrypt a folder which, if my laptop was taken by anyone else, noone would be able to get access to for any of my information.  This man page gives me information I need but I don't understand the 'archive' part.  Is this command suitable for encrypting a directory or what command is?  Thanks.

OpenPGP encryption is only defined on single files, there is no official way to define something like a folder structure, not to speak of permissions, file owners and other thing one might want to keep when encrypting folders.

The "unix way" in working around this is to create an archive, which is subsequently encrypted, which is explained in the GnuPG manual chapter "8.11 Encrypt or sign files into an archive" you referenced.

gpg-zip takes a folder as input, puts it into a tar archive which is finally encrypted, keeping an otherwise similar command line interface GnuPG does. Running gpg --list-packets on gpg-zip's output reveals what GnuPG is doing here (I used symmetric encryption here, but it works the same way using public/private key encryption), encrypting /tmp/foo while being in /tmp:

$ gpg-zip --symmetric foo | gpg --list-packets
:symkey enc packet: version 4, cipher 3, s2k 3, hash 10
    salt 640c284b119eb28c, count 102400 (105)
gpg: CAST5 encrypted data
:encrypted data packet:
    length: 183
gpg: encrypted with 1 passphrase
:compressed packet: algo=1
:literal data packet:
    mode b (62), created 1445875407, name="x.tar",
    raw data: unknown length
gpg: WARNING: message was not integrity protected

x.tar is the file you would also get as result when decrypting the file manually.


RFC 5246 TLS 1.2: padding example mistake? From RFC 5246, page 22:

Example: If the block length is 8 bytes, the content length
(TLSCompressed.length) is 61 bytes, and the MAC length is 20 bytes,
then the length before padding is 82 bytes (this does not include the
IV.  Thus, the padding length modulo 8 must be equal to 6 in order to
make the total length an even multiple of 8 bytes (the block length).
The padding length can be 6, 14, 22, and so on, through 254.  If the
padding length were the minimum necessary, 6, the padding would be 6
bytes, each containing the value 6.  Thus, the last 8 octets of the
GenericBlockCipher before block encryption would be xx 06 06 06 06 06
06 06, where xx is the last octet of the MAC.

So, 61+20=82, last 8 octets contains seven 06? Did I misunderstand something? Or such important document contains mistake?

The document is correct, xx is the last octet of the MAC, followed by six times the 06 octet as padding, followed by the length octet (06). The last length octet is not part of the padding.

See the definition of GenericBlockCipher in section 6.2.3.2 of RFC 5246:

struct {
    opaque IV[SecurityParameters.record_iv_length];
    block-ciphered struct {
        opaque content[TLSCompressed.length];
        opaque MAC[SecurityParameters.mac_length];
        uint8 padding[GenericBlockCipher.padding_length];
        uint8 padding_length;
    };
} GenericBlockCipher;


Secure REST API without a user registration I have an API in Node JS with mostly GET endpoints and a client side single page application.

The application is meant to be open without the need to authenticate, i.e like booking.com where you can browse hotels without the need to login or register.

Anyone can hit my endpoints and get raw JSON data or even make an app that utilize my endpoints in their own app.

How can I secure my endpoint? For example with a token based or any other signature to trust my client app only.

You cannot secure any secret that is public. If the HTML page sent to the client have the API keys, they are not secret anymore. Anyone can read the page and grab the key, and use it as they want.

Don't even think about encoding, obfuscating or encrypting it client-side either. The developer tools on any modern browser will let the user see the actual request, and they will just grab the keys on the request. Even if the application is a binary with encryption and anti-tamper, and uses SSL with certificate pining, a determined user will grab the keys. It can take seconds or days, but the key will leak.

To protect the keys, use a proxy. Make a server side component that holds the keys and access the backend, and your HTML page (or app, or Java, or whatever client application) will access it.

And you cannot really know if the client connecting is your client. Even MMO game producers have trouble dealing with alternative clients used to bypass some protections. You can only make it harder, but again, a determined attacker can bypass your protections.