summaryrefslogtreecommitdiff
path: root/apt-pkg/acquire-item.h
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-05-18 22:15:06 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-05-18 22:15:06 +0200
commit6bf93605fdb8e858d3f0a79a124c1d39f760094d (patch)
tree4f1fb6549db04d6b39845e8587316460b493f249 /apt-pkg/acquire-item.h
parent8eafc759544298211cd0bfaa3919afc0fadd47d1 (diff)
treat older Release files than we already have as an IMSHit
Valid-Until protects us from long-living downgrade attacks, but not all repositories have it and an attacker could still use older but still valid files to downgrade us. While this makes it sounds like a security improvement now, its a bit theoretical at best as an attacker with capabilities to pull this off could just as well always keep us days (but in the valid period) behind and always knows which state we have, as we tell him with the If-Modified-Since header. This is also why this is 'silently' ignored and treated as an IMSHit rather than screamed at the user as this can at best be an annoyance for attackers. An error here would 'regularily' be encountered by users by out-of-sync mirrors serving a single run (e.g. load balancer) or in two consecutive runs on the other hand, so it would just help teaching people ignore it. That said, most of the code churn is caused by enforcing this additional requirement. Crisscross from InRelease to Release.gpg is e.g. very unlikely in practice, but if we would ignore it an attacker could sidestep it this way.
Diffstat (limited to 'apt-pkg/acquire-item.h')
-rw-r--r--apt-pkg/acquire-item.h105
1 files changed, 55 insertions, 50 deletions
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index 646de8416..07c86f31b 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -394,6 +394,7 @@ class pkgAcqMetaBase : public pkgAcquire::Item /*{{{*/
/** \brief A package-system-specific parser for the meta-index file. */
indexRecords *MetaIndexParser;
+ indexRecords *LastMetaIndexParser;
/** \brief The index files which should be looked up in the meta-index
* and then downloaded.
@@ -429,11 +430,10 @@ class pkgAcqMetaBase : public pkgAcquire::Item /*{{{*/
* \param Message The message block received from the fetch
* subprocess.
*/
- bool CheckDownloadDone(const std::string &Message, HashStringList const &Hashes);
+ bool CheckDownloadDone(pkgAcquire::Item * const I, const std::string &Message, HashStringList const &Hashes) const;
/** \brief Queue the downloaded Signature for verification */
- void QueueForSignatureVerify(const std::string &MetaIndexFile,
- const std::string &MetaIndexFileSignature);
+ void QueueForSignatureVerify(pkgAcquire::Item * const I, std::string const &File, std::string const &Signature);
#if APT_PKG_ABI >= 413
virtual std::string Custom600Headers() const;
@@ -453,7 +453,7 @@ class pkgAcqMetaBase : public pkgAcquire::Item /*{{{*/
bool CheckAuthDone(std::string Message);
/** Check if the current item should fail at this point */
- bool CheckStopAuthentication(const std::string &Message);
+ bool CheckStopAuthentication(pkgAcquire::Item * const I, const std::string &Message);
/** \brief Check that the release file is a release file for the
* correct distribution.
@@ -462,8 +462,7 @@ class pkgAcqMetaBase : public pkgAcquire::Item /*{{{*/
*/
bool VerifyVendor(std::string Message);
- /** \brief Get the full pathname of the final file for the current URI */
- virtual std::string GetFinalFilename() const;
+ virtual bool TransactionState(TransactionStates const state);
public:
// This refers more to the Transaction-Manager than the actual file
@@ -487,6 +486,9 @@ class pkgAcqMetaBase : public pkgAcquire::Item /*{{{*/
*/
void TransactionStageRemoval(Item *I, const std::string &FinalFile);
+ /** \brief Get the full pathname of the final file for the current URI */
+ virtual std::string GetFinalFilename() const;
+
pkgAcqMetaBase(pkgAcquire *Owner,
const std::vector<IndexTarget*>* IndexTargets,
indexRecords* MetaIndexParser,
@@ -495,50 +497,6 @@ class pkgAcqMetaBase : public pkgAcquire::Item /*{{{*/
pkgAcqMetaBase *TransactionManager=NULL);
};
/*}}}*/
-/** \brief An acquire item that downloads the detached signature {{{
- * of a meta-index (Release) file, then queues up the release
- * file itself.
- *
- * \todo Why protected members?
- *
- * \sa pkgAcqMetaIndex
- */
-class APT_HIDDEN pkgAcqMetaSig : public pkgAcqMetaBase
-{
- void *d;
-
- protected:
-
- /** \brief The file we need to verify */
- std::string MetaIndexFile;
-
- /** \brief The file we use to verify the MetaIndexFile with */
- std::string MetaIndexFileSignature;
-
- /** \brief Long URI description used in the acquire system */
- std::string URIDesc;
-
- /** \brief Short URI description used in the acquire system */
- std::string ShortDesc;
-
- public:
-
- // Specialized action members
- virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
- virtual void Done(std::string Message,unsigned long long Size,
- HashStringList const &Hashes,
- pkgAcquire::MethodConfig *Cnf);
-
- /** \brief Create a new pkgAcqMetaSig. */
- pkgAcqMetaSig(pkgAcquire *Owner,
- pkgAcqMetaBase *TransactionManager,
- std::string URI,std::string URIDesc, std::string ShortDesc,
- std::string MetaIndexFile,
- const std::vector<IndexTarget*>* IndexTargets,
- indexRecords* MetaIndexParser);
- virtual ~pkgAcqMetaSig();
-};
- /*}}}*/
/** \brief An item that is responsible for downloading the meta-index {{{
* file (i.e., Release) itself and verifying its signature.
*
@@ -584,6 +542,53 @@ class APT_HIDDEN pkgAcqMetaIndex : public pkgAcqMetaBase
std::string MetaIndexSigURI, std::string MetaIndexSigURIDesc, std::string MetaIndexSigShortDesc,
const std::vector<IndexTarget*>* IndexTargets,
indexRecords* MetaIndexParser);
+
+ friend class pkgAcqMetaSig;
+};
+ /*}}}*/
+/** \brief An acquire item that downloads the detached signature {{{
+ * of a meta-index (Release) file, then queues up the release
+ * file itself.
+ *
+ * \todo Why protected members?
+ *
+ * \sa pkgAcqMetaIndex
+ */
+class APT_HIDDEN pkgAcqMetaSig : public pkgAcquire::Item
+{
+ void *d;
+
+ pkgAcqMetaIndex * const MetaIndex;
+
+ /** \brief The file we use to verify the MetaIndexFile with (not always set!) */
+ std::string MetaIndexFileSignature;
+
+ protected:
+
+ /** \brief Long URI description used in the acquire system */
+ std::string URIDesc;
+
+ /** \brief URI used to get the file */
+ std::string RealURI;
+
+ /** \brief Get the full pathname of the final file for the current URI */
+ virtual std::string GetFinalFilename() const;
+
+ public:
+ virtual std::string DescURI() {return RealURI;};
+
+ // Specialized action members
+ virtual void Failed(std::string Message,pkgAcquire::MethodConfig *Cnf);
+ virtual void Done(std::string Message,unsigned long long Size,
+ HashStringList const &Hashes,
+ pkgAcquire::MethodConfig *Cnf);
+
+ /** \brief Create a new pkgAcqMetaSig. */
+ pkgAcqMetaSig(pkgAcquire *Owner,
+ pkgAcqMetaBase *TransactionManager,
+ std::string const &URI,std::string const &URIDesc,
+ std::string const &ShortDesc, pkgAcqMetaIndex * const MetaIndex);
+ virtual ~pkgAcqMetaSig();
};
/*}}}*/
/** \brief An item repsonsible for downloading clearsigned metaindexes {{{*/